diff --git a/includes/destinations.db.mysql.inc b/includes/destinations.db.mysql.inc index 1b8a1cf..0ce6713 100644 --- a/includes/destinations.db.mysql.inc +++ b/includes/destinations.db.mysql.inc @@ -212,12 +212,12 @@ public function _restore_db_from_file($file, $settings) { $num = 0; if ($file->open() && $conn = $this->_get_db_connection()) { - if ($settings->filters['utils_drop_all_tables']) { - // Drop all existing tables. - $all_tables = $this->_get_tables(); + // Optionally drop all existing tables. + if (!empty($settings->filters['utils_drop_all_tables'])) { + $all_tables = $this->_get_tables(); $table_names = array_map(create_function('$a', 'return "`" . $a["name"] . "`";'), $all_tables); - $table_list = join(', ', $table_names); - $stmt = $conn->prepare("DROP TABLE IF EXISTS $table_list;\n"); + $table_list = join(', ', $table_names); + $stmt = $conn->prepare("DROP TABLE IF EXISTS $table_list;\n"); $stmt->execute(); } diff --git a/includes/sources.db.mysql.inc b/includes/sources.db.mysql.inc index f203048..fe47c93 100644 --- a/includes/sources.db.mysql.inc +++ b/includes/sources.db.mysql.inc @@ -200,14 +200,15 @@ public function _restore_db_from_file($file, $settings) { $num = 0; if ($file->open() && $conn = $this->_get_db_connection()) { - if ($settings->filters['utils_drop_all_tables']) { - // Drop all existing tables. - $all_tables = $this->_get_tables(); + // Optionally drop all existing tables. + if (!empty($settings->filters['utils_drop_all_tables'])) { + $all_tables = $this->_get_tables(); $table_names = array_map(create_function('$a', 'return "`" . $a["name"] . "`";'), $all_tables); - $table_list = join(', ', $table_names); - $stmt = $conn->prepare("DROP TABLE IF EXISTS $table_list;\n"); + $table_list = join(', ', $table_names); + $stmt = $conn->prepare("DROP TABLE IF EXISTS $table_list;\n"); $stmt->execute(); } + // Read one line at a time and run the query. while ($line = $this->_read_sql_command_from_file($file)) { if (_backup_migrate_check_timeout()) {