Elgg  Version 4.3
database.php
Go to the documentation of this file.
1 <?php
3 
4 // show database statistics
5 
6 $tables = [
7  'access_collections',
8  'access_collection_membership',
9  'annotations',
10  'api_users',
11  'config',
12  'delayed_email_queue',
13  'entities',
14  'entity_relationships',
15  'hmac_cache',
16  'metadata',
17  'private_settings',
18  'queue',
19  'river',
20  'system_log',
21  'users_apisessions',
22  'users_remember_me_cookies',
23  'users_sessions',
24 ];
25 
26 $header = '<tr><th>' . elgg_echo('admin:statistics:database:table') . '</th>';
27 $header .= '<th>' . elgg_echo('admin:statistics:database:row_count') . '</th></tr>';
28 
29 $rows = '';
30 foreach ($tables as $table_name) {
31  $qb = Select::fromTable($table_name);
32  $qb->select("COUNT(*) AS total");
33 
34  $row_count = _elgg_services()->db->getDataRow($qb);
35  $row_count = empty($row_count) ? 0 : (int) $row_count->total;
36 
37  $rows .= "<tr><td>{$table_name}</td><td>{$row_count}</td></tr>";
38 }
39 
40 $body = "<table class='elgg-table'><thead>{$header}</thead><tbody>{$rows}</tbody></table>";
41 
42 echo elgg_view_module('info', elgg_echo('admin:statistics:database'), $body);
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
$header
Definition: database.php:26
foreach($tables as $table_name) $body
Definition: database.php:40
elgg_view_module($type, $title, $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:950
$tables
Definition: database.php:6
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638
elgg echo
Translates a string.
Definition: deprecated.js:530
$rows
Definition: database.php:29
$qb
Definition: queue.php:11