Folder reorganize 1
This commit is contained in:
38
scripts/test-control-log.php
Normal file
38
scripts/test-control-log.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php // phpcs:ignoreFile
|
||||
|
||||
require __DIR__ . '/../includes/db.php';
|
||||
|
||||
try {
|
||||
$db = controls_db_connect();
|
||||
echo "Connected to MySQL successfully.\n";
|
||||
|
||||
$table = 'control_write_log';
|
||||
if ($argc > 1 && is_string($argv[1]) && $argv[1] !== '') {
|
||||
$table = $argv[1];
|
||||
}
|
||||
|
||||
$tableEscaped = $db->real_escape_string($table);
|
||||
$check = $db->query("SHOW TABLES LIKE '" . $tableEscaped . "'");
|
||||
if (!$check) {
|
||||
echo "SHOW TABLES query failed.\n";
|
||||
}
|
||||
|
||||
$exists = $check && $check->num_rows > 0;
|
||||
if ($exists) {
|
||||
echo "Table '{$table}' exists.\n";
|
||||
} else {
|
||||
echo "Table '{$table}' does not exist.\n";
|
||||
}
|
||||
|
||||
if ($exists) {
|
||||
$columns = $db->query('SHOW COLUMNS FROM `' . $tableEscaped . '`');
|
||||
if ($columns) {
|
||||
echo "Columns:\n";
|
||||
while ($column = $columns->fetch_assoc()) {
|
||||
echo ' - ' . ($column['Field'] ?? '(unknown)') . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable $exception) {
|
||||
echo 'Error: ' . $exception->getMessage() . "\n";
|
||||
}
|
||||
Reference in New Issue
Block a user