38471-vm/db_inspect.php
2026-02-25 09:58:14 +00:00

18 lines
500 B
PHP

<?php
require 'db/config.php';
try {
$pdo = db();
$stmt = $pdo->query("SHOW TABLES");
$tables = $stmt->fetchAll(PDO::FETCH_COLUMN);
foreach ($tables as $table) {
echo "Table: $table\n";
$stmt2 = $pdo->query("DESCRIBE `$table`");
$cols = $stmt2->fetchAll(PDO::FETCH_ASSOC);
foreach ($cols as $col) {
echo " - " . $col['Field'] . " (" . $col['Type'] . ")\n";
}
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}