Elgg  Version 6.3
database.php
Go to the documentation of this file.
1 <?php
7 
8 $tables = [
9  'access_collections',
10  'access_collection_membership',
11  'annotations',
12  'api_users',
13  'config',
14  'delayed_email_queue',
15  'entities',
16  'entity_relationships',
17  'hmac_cache',
18  'metadata',
19  'queue',
20  'river',
21  'system_log',
22  'users_apisessions',
23  'users_remember_me_cookies',
24  'users_sessions',
25 ];
26 
28  elgg_format_element('th', [], elgg_echo('admin:statistics:database:table')),
29  elgg_format_element('th', [], elgg_echo('admin:statistics:database:row_count')),
30 ];
31 $header = elgg_format_element('tr', [], implode(PHP_EOL, $header));
32 $header = elgg_format_element('thead', [], $header);
33 
34 $rows = [];
35 foreach ($tables as $table_name) {
36  $row = [];
37 
38  $qb = Select::fromTable($table_name);
39  $qb->select('COUNT(*) AS total');
40 
41  $row_count = _elgg_services()->db->getDataRow($qb);
42  $row_count = empty($row_count) ? 0 : (int) $row_count->total;
43 
44  $row[] = elgg_format_element('td', [], $table_name);
45  $row[] = elgg_format_element('td', [], elgg_number_format($row_count));
46 
47  $rows[] = elgg_format_element('tr', [], implode(PHP_EOL, $row));
48 }
49 
50 $body = elgg_format_element('tbody', [], implode(PHP_EOL, $rows));
51 
52 $table = elgg_format_element('table', ['class' => 'elgg-table'], $header . $body);
53 
54 echo elgg_view_module('info', elgg_echo('admin:statistics:database'), $table);
Query builder for fetching data from the database.
Definition: Select.php:8
$tables
Definition: database.php:8
$header
Definition: database.php:27
foreach($tables as $table_name) $body
Definition: database.php:50
$rows
Definition: database.php:34
$table
Definition: database.php:52
_elgg_services()
Get the global service provider.
Definition: elgglib.php:337
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_view_module(string $type, string $title, string $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:922
elgg_format_element(string $tag_name, array $attributes=[], string $text='', array $options=[])
Format an HTML element.
Definition: output.php:145
elgg_number_format(float $number, int $decimals=0)
Format a number with grouped thousands using language specific separators.
Definition: output.php:368
$qb
Definition: queue.php:14