diff --git a/db_operations.php b/db_operations.php index 8677fb5b75..b81a7ecbaa 100644 --- a/db_operations.php +++ b/db_operations.php @@ -87,8 +87,6 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { // go back to current db, just in case PMA_DBI_select_db($db); - $GLOBALS['sql_constraints_query_full_db'] = array(); - $tables_full = PMA_DBI_get_tables_full($db); require_once "libraries/plugin_interface.lib.php"; @@ -102,7 +100,10 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { 'single_table' => isset($single_table) ) ); - PMA_removeAllForeignKeyConstraints($tables_full, $export_sql_plugin, $move); + $GLOBALS['sql_constraints_query_full_db'] = + PMA_getSqlConstraintsQueryForFullDb( + $tables_full, $export_sql_plugin, $move + ); $views = PMA_getViewsAndCreateSqlViewStandIn($tables_full, $export_sql_plugin); diff --git a/libraries/db_operations.lib.php b/libraries/db_operations.lib.php index 51e07aac3f..382a8748bd 100644 --- a/libraries/db_operations.lib.php +++ b/libraries/db_operations.lib.php @@ -338,14 +338,15 @@ function PMA_getSqlQueryAndCreateDbBeforeCopy() } /** - * remove all foreign key constraints + * remove all foreign key constraints and return sql constraints query for full database * * @param array $tables_full array of all tables in given db or dbs * @param instance $export_sql_plugin export plugin instance * @param boolean $move whether databse name is empty or not */ -function PMA_removeAllForeignKeyConstraints($tables_full, $export_sql_plugin, $move) +function PMA_getSqlConstraintsQueryForFullDb($tables_full, $export_sql_plugin, $move) { + $sql_constraints_query_full_db = array(); foreach ($tables_full as $each_table => $tmp) { $sql_constraints = ''; $sql_drop_foreign_keys = ''; @@ -357,9 +358,10 @@ function PMA_removeAllForeignKeyConstraints($tables_full, $export_sql_plugin, $m } // keep the constraint we just dropped if (! empty($sql_constraints)) { - $GLOBALS['sql_constraints_query_full_db'][] = $sql_constraints; + $sql_constraints_query_full_db[] = $sql_constraints; } } + return $sql_constraints_query_full_db; } /**