Elgg  Version master
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  'queue',
18  'river',
19  'system_log',
20  'users_apisessions',
21  'users_remember_me_cookies',
22  'users_sessions',
23 ];
24 
25 $header = '<tr><th>' . elgg_echo('admin:statistics:database:table') . '</th>';
26 $header .= '<th>' . elgg_echo('admin:statistics:database:row_count') . '</th></tr>';
27 
28 $rows = '';
29 foreach ($tables as $table_name) {
30  $qb = Select::fromTable($table_name);
31  $qb->select('COUNT(*) AS total');
32 
33  $row_count = _elgg_services()->db->getDataRow($qb);
34  $row_count = empty($row_count) ? 0 : (int) $row_count->total;
35 
36  $rows .= "<tr><td>{$table_name}</td><td>{$row_count}</td></tr>";
37 }
38 
39 $body = "<table class='elgg-table'><thead>{$header}</thead><tbody>{$rows}</tbody></table>";
40 
41 echo elgg_view_module('info', elgg_echo('admin:statistics:database'), $body);
elgg_view_module(string $type, string $title, string $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:940
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$header
Definition: database.php:25
foreach($tables as $table_name) $body
Definition: database.php:39
$tables
Definition: database.php:6
_elgg_services()
Get the global service provider.
Definition: elgglib.php:346
$rows
Definition: database.php:28
$qb
Definition: queue.php:11