|
|
@@ -18,7 +18,7 @@ class Route_Status extends RouteBase {
|
|
|
try {
|
|
|
DB::getPDO();
|
|
|
|
|
|
- $this->runPostTask();
|
|
|
+ $this->runPostTask(); // _postTask = $this->"{$_POST['_postTask']}PostTask"()
|
|
|
|
|
|
$this->viewStatusDatabase();
|
|
|
|
|
|
@@ -76,7 +76,16 @@ class Route_Status extends RouteBase {
|
|
|
$totalToUpdateRef = RefConfig::getToUpdateTotal();
|
|
|
|
|
|
UI::table([
|
|
|
- 'caption' => UI::h('b', ['style' => "color:#000"], 'Baza danych'),
|
|
|
+ 'caption' => UI::h('b', ['style' => "color:#000"], [
|
|
|
+ "Baza danych",
|
|
|
+ " ",
|
|
|
+ UI::hButtonPost("sprawdź tabele", [
|
|
|
+ 'class' => "btn btn-xs btn-default",
|
|
|
+ 'data' => [
|
|
|
+ '_postTask' => 'checkDatabaseTables',
|
|
|
+ ]
|
|
|
+ ]),
|
|
|
+ ]),
|
|
|
'rows' => [
|
|
|
[
|
|
|
'nazwa' => "Event Scheduler (generowanie Grafika, itp.)",
|
|
|
@@ -354,4 +363,57 @@ class Route_Status extends RouteBase {
|
|
|
];
|
|
|
}
|
|
|
|
|
|
+ function checkDatabaseTablesPostTask() {
|
|
|
+ $pdo = DB::getPDO();
|
|
|
+ // DBG::nicePrint($pdo, "DB Info");
|
|
|
+ // DBG::nicePrint(get_class_methods($pdo), "pdo methods");
|
|
|
+ $tblName = V::get('_fixTable', '', $_POST);
|
|
|
+ if (!empty($tblName)) {
|
|
|
+ $sqlTableName = DB::getPDO()->identifierQuote($tblName);
|
|
|
+ $fixReturn = DB::getPDO()->fetchAll(" repair table {$sqlTableName} ");
|
|
|
+ echo UI::hTable([ 'caption' => "Naprawa tabeli '{$tblName}':", 'rows' => $fixReturn ]);
|
|
|
+ $lastFixRow = end($fixReturn);
|
|
|
+ if ('OK' === V::get('Msg_text', '', $lastFixRow)) {
|
|
|
+ UI::alert('success', "Naprawiono tabelę '{$tblName}'");
|
|
|
+ } else {
|
|
|
+ UI::alert('danger', "Nie udało się naprawić tabeli '{$tblName}'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $listTables = DB::getPDO()->fetchValuesList("
|
|
|
+ select TABLE_NAME
|
|
|
+ from INFORMATION_SCHEMA.TABLES
|
|
|
+ where TABLE_SCHEMA = :db_name
|
|
|
+ and TABLE_TYPE = 'BASE TABLE'
|
|
|
+ ", [
|
|
|
+ ':db_name' => DB::getPDO()->getDatabaseName(),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ DBG::nicePrint($listTables, "all tables");
|
|
|
+ // $listTables = array_slice($listTables, 0, 10); // TODO: DBG
|
|
|
+ UI::table([
|
|
|
+ 'rows' => array_map(function ($tblName) {
|
|
|
+
|
|
|
+ $fixTableBtn = UI::hButtonPost("napraw tabele", [
|
|
|
+ 'class' => "btn btn-xs btn-primary",
|
|
|
+ 'data' => [
|
|
|
+ '_postTask' => 'checkDatabaseTables',
|
|
|
+ '_fixTable' => $tblName,
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ return [
|
|
|
+ 'table' => $tblName,
|
|
|
+ 'status' => UI::h('details', [ 'open' => '' ], [
|
|
|
+ UI::h('summary', [], [
|
|
|
+ "check table `{$tblName}`",
|
|
|
+ " ",
|
|
|
+ $fixTableBtn,
|
|
|
+ ]),
|
|
|
+ UI::hTable([ 'rows' => DB::getPDO()->fetchAll(" check table `{$tblName}` ") ]),
|
|
|
+ ]),
|
|
|
+ ];
|
|
|
+ }, $listTables)
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
}
|