From cc3ae458322dfdafc5f404e2117aae6774e18ebb Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Tue, 13 Oct 2009 20:08:58 +0000 Subject: [PATCH] Disable foreign_key_checks only with drop and truncate git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1191 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- adminer/db.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adminer/db.inc.php b/adminer/db.inc.php index e74b8ffa..d2fe5f59 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -4,7 +4,7 @@ $tables_views = array_merge((array) $_POST["tables"], (array) $_POST["views"]); if ($tables_views && !$error) { $result = true; $message = ""; - if (count($_POST["tables"]) > 1) { + if (count($_POST["tables"]) > 1 && ($_POST["drop"] || $_POST["truncate"])) { queries("SET foreign_key_checks = 0"); // allows to truncate or drop several tables at once } if (isset($_POST["truncate"])) { @@ -21,6 +21,7 @@ if ($tables_views && !$error) { $rename[] = idf_escape($table) . " TO " . idf_escape($_POST["target"]) . "." . idf_escape($table); } $result = queries("RENAME TABLE " . implode(", ", $rename)); + //! move triggers $message = lang('Tables have been moved.'); } elseif ((!isset($_POST["drop"]) || !$_POST["views"] || queries("DROP VIEW " . implode(", ", array_map('idf_escape', $_POST["views"])))) && (!$_POST["tables"] || ($result = queries((isset($_POST["optimize"]) ? "OPTIMIZE" : (isset($_POST["check"]) ? "CHECK" : (isset($_POST["repair"]) ? "REPAIR" : (isset($_POST["drop"]) ? "DROP" : "ANALYZE")))) . " TABLE " . implode(", ", array_map('idf_escape', $_POST["tables"])))))