39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?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";
|
|
}
|