Table rowcount in Maintenance #253

This commit is contained in:
Jokob-sk
2023-06-18 08:31:05 +10:00
parent 2e713bf1d0
commit cee24e0b6c
3 changed files with 34 additions and 3 deletions

View File

@@ -118,6 +118,30 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
}
}
}
// Table sizes -----------------------------------------------------------------
$tableSizesHTML = "";
// Open a connection to the SQLite database
$db = new SQLite3($pia_db);
// Retrieve the table names from sqlite_master
$query = "SELECT name FROM sqlite_master WHERE type='table'";
$result = $db->query($query);
// Iterate over the tables and get the row counts
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$tableName = $row['name'];
$query = "SELECT COUNT(*) FROM $tableName";
$countResult = $db->querySingle($query);
$tableSizesHTML = $tableSizesHTML . "$tableName (<b>$countResult</b>), ";
}
// Close the database connection
$db->close();
// Language selector -----------------------------------------------------------------
@@ -152,6 +176,12 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<?php echo $pia_db_size;?>
</div>
</div>
<div class="db_info_table_row">
<div class="db_info_table_cell"><?= lang('Maintenance_database_rows');?></div>
<div class="db_info_table_cell">
<?php echo $tableSizesHTML;?>
</div>
</div>
<div class="db_info_table_row">
<div class="db_info_table_cell"><?= lang('Maintenance_database_lastmod');?></div>
<div class="db_info_table_cell">

View File

@@ -250,11 +250,12 @@ $lang['en_us'] = array(
//////////////////////////////////////////////////////////////////
'Maintenance_Title' => 'Maintenance tools',
'Maintenance_version' => 'Application updates',
'Maintenance_version' => 'App updates',
'Maintenance_new_version' => '🆕 A new version is available. Check out the <a href="https://github.com/jokob-sk/Pi.Alert/releases" target="_blank">release notes</a>.',
'Maintenance_current_version' => 'You are up-to-date. Check out what <a href="https://github.com/jokob-sk/Pi.Alert/issues/138" target="_blank">I\'m working on</a>.',
'Maintenance_database_path' => 'Database-Path',
'Maintenance_database_size' => 'Database-Size',
'Maintenance_database_rows' => 'Table (Rows)',
'Maintenance_database_lastmod' => 'Last Modification',
'Maintenance_database_backup' => 'DB Backups',
'Maintenance_database_backup_found' => 'backups were found',