Example #1
0
 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']);
 }
 unset($views);
 // now that all tables exist, create all the accumulated constraints
 if (!$_error && count($sqlConstratints) > 0) {
     PMA_createAllAccumulatedConstraints($sqlConstratints);
 }
 unset($sqlConstratints);
 if (PMA_MYSQL_INT_VERSION >= 50100) {
     // here DELIMITER is not used because it's not part of the
     // language; each statement is sent one by one
     PMA_runEventDefinitionsForDb($GLOBALS['db']);
 }
 // go back to current db, just in case
 $GLOBALS['dbi']->selectDb($GLOBALS['db']);
 // Duplicate the bookmarks for this db (done once for each db)
 PMA_duplicateBookmarks($_error, $GLOBALS['db']);
 if (!$_error && $move) {
     if (isset($_REQUEST['adjust_privileges']) && !empty($_REQUEST['adjust_privileges'])) {
         PMA_AdjustPrivileges_moveDB($GLOBALS['db'], $_REQUEST['newname']);
     }
 $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
 $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, $GLOBALS['db']);
 $views = PMA_getViewsAndCreateSqlViewStandIn($tables_full, $export_sql_plugin, $GLOBALS['db']);
 list($sql_query, $_error) = PMA_getSqlQueryForCopyTable($tables_full, $sql_query, $move, $GLOBALS['db']);
 // handle the views
 if (!$_error) {
     $_error = PMA_handleTheViews($views, $move, $GLOBALS['db']);
 }
 unset($views);
 // now that all tables exist, create all the accumulated constraints
 if (!$_error && count($GLOBALS['sql_constraints_query_full_db']) > 0) {
     PMA_createAllAccumulatedConstraints();
 }
 if (!PMA_DRIZZLE && PMA_MYSQL_INT_VERSION >= 50100) {
     // here DELIMITER is not used because it's not part of the
     // language; each statement is sent one by one
     PMA_runEventDefinitionsForDb($GLOBALS['db']);
 }
 // go back to current db, just in case
 $GLOBALS['dbi']->selectDb($GLOBALS['db']);
 // Duplicate the bookmarks for this db (done once for each db)
 PMA_duplicateBookmarks($_error, $GLOBALS['db']);
 if (!$_error && $move) {
     /**
      * cleanup pmadb stuff for this db
      */
     include_once 'libraries/relation_cleanup.lib.php';