Example #1
0
 } else {
     $move = false;
 }
 if (!isset($_REQUEST['newname']) || !mb_strlen($_REQUEST['newname'])) {
     $message = PMA\libraries\Message::error(__('The database name is empty!'));
 } else {
     $_error = false;
     if ($move || !empty($_REQUEST['create_database_before_copying'])) {
         PMA_createDbBeforeCopy();
     }
     // here I don't use DELIMITER because it's not part of the
     // language; I have to send each statement one by one
     // to avoid selecting alternatively the current and new db
     // we would need to modify the CREATE definitions to qualify
     // the db name
     PMA_runProcedureAndFunctionDefinitions($GLOBALS['db']);
     // go back to current db, just in case
     $GLOBALS['dbi']->selectDb($GLOBALS['db']);
     $tables_full = $GLOBALS['dbi']->getTablesFull($GLOBALS['db']);
     include_once "libraries/plugin_interface.lib.php";
     // remove all foreign key constraints, otherwise we can get errors
     /* @var $export_sql_plugin ExportSql */
     $export_sql_plugin = PMA_getPlugin("export", "sql", 'libraries/plugins/export/', array('single_table' => isset($single_table), 'export_type' => 'database'));
     // create stand-in tables for views
     $views = PMA_getViewsAndCreateSqlViewStandIn($tables_full, $export_sql_plugin, $GLOBALS['db']);
     // copy tables
     $sqlConstratints = PMA_copyTables($tables_full, $move, $GLOBALS['db']);
     // handle the views
     if (!$_error) {
         PMA_handleTheViews($views, $move, $GLOBALS['db']);
     }
Example #2
0
 }
 if (!isset($_REQUEST['newname']) || !strlen($_REQUEST['newname'])) {
     $message = PMA_Message::error(__('The database name is empty!'));
 } else {
     $sql_query = '';
     // in case target db exists
     $_error = false;
     if ($move || isset($_REQUEST['create_database_before_copying']) && $_REQUEST['create_database_before_copying']) {
         $sql_query = PMA_getSqlQueryAndCreateDbBeforeCopy();
     }
     // here I don't use DELIMITER because it's not part of the
     // language; I have to send each statement one by one
     // to avoid selecting alternatively the current and new db
     // we would need to modify the CREATE definitions to qualify
     // the db name
     PMA_runProcedureAndFunctionDefinitions($db);
     // go back to current db, just in case
     $GLOBALS['dbi']->selectDb($db);
     $tables_full = $GLOBALS['dbi']->getTablesFull($db);
     include_once "libraries/plugin_interface.lib.php";
     // remove all foreign key constraints, otherwise we can get errors
     $export_sql_plugin = PMA_getPlugin("export", "sql", 'libraries/plugins/export/', array('single_table' => isset($single_table), 'export_type' => 'database'));
     $GLOBALS['sql_constraints_query_full_db'] = PMA_getSqlConstraintsQueryForFullDb($tables_full, $export_sql_plugin, $move, $db);
     $views = PMA_getViewsAndCreateSqlViewStandIn($tables_full, $export_sql_plugin, $db);
     list($sql_query, $_error) = PMA_getSqlQueryForCopyTable($tables_full, $sql_query, $move, $db);
     // handle the views
     if (!$_error) {
         $_error = PMA_handleTheViews($views, $move, $db);
     }
     unset($views);
     // now that all tables exist, create all the accumulated constraints