setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } if ($dump_all) { $tables = array(); if ($db_driver === "mysqli") { $res = mysqli_query($link, "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA='$database'"); while ($row = $res->fetch_assoc()) { $tables[] = $row["TABLE_NAME"]; } } else if ($db_driver === "PDO") { $stmt = $link->query("SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA='$database'"); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $tables[] = $row["TABLE_NAME"]; } } foreach ($tables as $tableName) { echo "-- DATA FOR TABLE: tableName\n"; if ($db_driver === "mysqli") { $res = mysqli_query($link, "SELECT * FROM $tableName"); while ($row = $res->fetch_assoc()) { print_r($row); } } else if ($db_driver === "PDO") { $stmt = $link->query("SELECT * FROM $tableName"); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { print_r($row); } } echo "-- --------------------------\n\n"; } } else { if ($db_driver === "mysqli") { $res = mysqli_query($link, $query); if (!$res) { die("Error executing query: " . mysqli_error($link)); } while ($row = $res->fetch_assoc()) { print_r($row); } } else if ($db_driver === "PDO") { $stmt = $link->query($query); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { print_r($row); } } } if ($db_driver === "mysqli") { mysqli_close($link); } ?>