From: Jakub Vrana Date: Fri, 18 Jun 2010 14:38:06 +0000 (+0200) Subject: Rename tables by single command X-Git-Tag: v3.0.0~72 X-Git-Url: https://git.joonet.de/?a=commitdiff_plain;h=515325ac227e79fdf73353e1714bdd20853d3034;p=adminer.git Rename tables by single command --- diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 4e8b6c38..307a9aba 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -544,22 +544,18 @@ if (!defined("DRIVER")) { */ function rename_database($name, $collation) { global $connection; - $return = false; if (create_database($name, $collation)) { //! move triggers - $return = true; // table list may by empty - foreach (tables_list() as $table) { - if (!queries("RENAME TABLE " . table($table) . " TO " . idf_escape($name) . "." . table($table))) { - $return = false; - break; - } + $rename = array(); + foreach (tables_list() as $table => $type) { + $rename[] = table($table) . " TO " . idf_escape($name) . "." . table($table); } - if ($return) { + if (!$rename || queries("RENAME TABLE " . implode(", ", $rename))) { queries("DROP DATABASE " . idf_escape(DB)); - //! saved to history of removed database + return true; } } - return $return; + return false; } /** Generate modifier for auto increment column