exec("SET FOREIGN_KEY_CHECKS = 0");
// Get all tables
$stmt = $pdo->query("SHOW TABLES");
$tables = $stmt->fetchAll(PDO::FETCH_COLUMN);
echo "
Resetting Database
";
echo "";
foreach ($tables as $table) {
$pdo->exec("TRUNCATE TABLE `$table`");
echo "- Truncated table: $table
";
}
echo "
";
$pdo->exec("SET FOREIGN_KEY_CHECKS = 1");
echo "Semua data di database berhasil dikosongkan! Sisa tabel dan strukturnya saja.
";
echo "Kembali ke beranda";
} catch (PDOException $e) {
echo "Gagal mengosongkan database: " . $e->getMessage();
}
?>