]> git.joonet.de Git - adminer.git/commitdiff
Use common code
authorJakub Vrana <jakub@vrana.cz>
Fri, 12 Feb 2021 09:49:31 +0000 (10:49 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 12 Feb 2021 10:28:55 +0000 (11:28 +0100)
adminer/drivers/mysql.inc.php

index bfaa166fb86a8529063bfd949e25f7627a22e27f..d77289ecb19a14110ad84fd5bd6b25d0f6786883 100644 (file)
@@ -678,17 +678,17 @@ if (!defined("DRIVER")) {
        function rename_database($name, $collation) {
                $return = false;
                if (create_database($name, $collation)) {
-                       //! move triggers
-                       $rename = array();
+                       $tables = array();
+                       $views = array();
                        foreach (tables_list() as $table => $type) {
-                               $rename[] = table($table) . " TO " . idf_escape($name) . "." . table($table);
-                       }
-                       $return = (!$rename || queries("RENAME TABLE " . implode(", ", $rename)));
-                       if ($return) {
-                               queries("DROP DATABASE " . idf_escape(DB));
+                               if ($type == 'VIEW') {
+                                       $views[] = $table;
+                               } else {
+                                       $tables[] = $table;
+                               }
                        }
-                       restart_session();
-                       set_session("dbs", null);
+                       $return = (!$tables && !$views) || move_tables($tables, $views, $name);
+                       drop_databases($return ? array(DB) : array());
                }
                return $return;
        }