39728-vm/dump_schema.php
2026-04-20 05:26:38 +00:00

16 lines
437 B
PHP

<?php
require_once 'db/config.php';
$pdo = db();
$stmt = $pdo->query("SHOW TABLES");
$tables = $stmt->fetchAll(PDO::FETCH_COLUMN);
$sql = "SET FOREIGN_KEY_CHECKS=0;
";
foreach ($tables as $table) {
$createStmt = $pdo->query("SHOW CREATE TABLE `$table`")->fetch(PDO::FETCH_ASSOC);
$sql .= "-- Table structure for `$table`\n";
$sql .= $createStmt['Create Table'] . ";\n\n";
}
$sql .= "SET FOREIGN_KEY_CHECKS=1;\n";
echo $sql;