build(); } if (isset($GLOBALS['add_constraints'])) { $GLOBALS['sql_constraints_query_full_db'] = ''; } $tables_full = PMA_DBI_get_tables_full($db); $views = array(); foreach ($tables_full as $each_table => $tmp) { // to be able to rename a db containing views, we // first collect in $views all the views we find and we // will handle them after the tables /** * @todo support a view of a view * @todo support triggers */ if (PMA_Table::isView($db, $each_table)) { $views[] = $each_table; continue; } $back = $sql_query; $sql_query = ''; // value of $what for this table only $this_what = $what; if (!isset($tables_full[$each_table]['Engine'])) { $tables_full[$each_table]['Engine'] = $tables_full[$each_table]['Type']; } // do not copy the data from a Merge table // note: on the calling FORM, 'data' means 'structure and data' if ($tables_full[$each_table]['Engine'] == 'MRG_MyISAM') { if ($this_what == 'data') { $this_what = 'structure'; } if ($this_what == 'dataonly') { $this_what = 'nocopy'; } } if ($this_what != 'nocopy') { PMA_Table::moveCopy($db, $each_table, $newname, $each_table, isset($this_what) ? $this_what : 'data', $move, 'db_copy'); if (isset($GLOBALS['add_constraints'])) { $GLOBALS['sql_constraints_query_full_db'] .= $GLOBALS['sql_constraints_query']; unset($GLOBALS['sql_constraints_query']); } } $sql_query = $back . $sql_query; } // end (foreach) unset($each_table); // handle the views foreach ($views as $view) { PMA_Table::moveCopy($db, $view, $newname, $view, 'structure', $move, 'db_copy'); } unset($view, $views); // now that all tables exist, create all the accumulated constraints if (isset($GLOBALS['add_constraints'])) { /** * @todo this works with mysqli but not with mysql, because * mysql extension does not accept more than one statement; maybe * interface with the sql import plugin that handles statement delimiter */ PMA_DBI_query($GLOBALS['sql_constraints_query_full_db']); // and prepare to display them $GLOBALS['sql_query'] .= "\n" . $GLOBALS['sql_constraints_query_full_db']; unset($GLOBALS['sql_constraints_query_full_db']); } if (PMA_MYSQL_INT_VERSION >= 50000) { // 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 $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE'); if ($procedure_names) { foreach($procedure_names as $procedure_name) { PMA_DBI_select_db($db); $tmp_query = PMA_DBI_get_procedure_or_function_def($db, 'PROCEDURE', $procedure_name); // collect for later display $GLOBALS['sql_query'] .= "\n" . $tmp_query; PMA_DBI_select_db($newname); PMA_DBI_query($tmp_query); } } $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION'); if ($function_names) { foreach($function_names as $function_name) { PMA_DBI_select_db($db); $tmp_query = PMA_DBI_get_procedure_or_function_def($db, 'FUNCTION', $function_name); // collect for later display $GLOBALS['sql_query'] .= "\n" . $tmp_query; PMA_DBI_select_db($newname); PMA_DBI_query($tmp_query); } } } // go back to current db, just in case PMA_DBI_select_db($db); // Duplicate the bookmarks for this db (done once for each db) if ($db != $newname) { $get_fields = array('user', 'label', 'query'); $where_fields = array('dbase' => $db); $new_fields = array('dbase' => $newname); PMA_Table::duplicateInfo('bookmarkwork', 'bookmark', $get_fields, $where_fields, $new_fields); } if ($move) { // cleanup pmadb stuff for this db require_once './libraries/relation_cleanup.lib.php'; PMA_relationsCleanupDatabase($db); // if someday the RENAME DATABASE reappears, do not DROP $local_query = 'DROP DATABASE ' . PMA_backquote($db) . ';'; $sql_query .= "\n" . $local_query; PMA_DBI_query($local_query); $message = sprintf($strRenameDatabaseOK, htmlspecialchars($db), htmlspecialchars($newname)); } else { $message = sprintf($strCopyDatabaseOK, htmlspecialchars($db), htmlspecialchars($newname)); } $reload = true; /* Change database to be used */ if ($move) { $db = $newname; } else { if (isset($switch_to_new) && $switch_to_new == 'true') { PMA_setCookie('pma_switch_to_new', 'true'); $db = $newname; } else { PMA_setCookie('pma_switch_to_new', ''); } } } } /** * Settings for relations stuff */ require_once './libraries/relation.lib.php'; $cfgRelation = PMA_getRelationsParam(); /** * Check if comments were updated * (must be done before displaying the menu tabs) */ if ($cfgRelation['commwork'] && isset($db_comment) && $db_comment == 'true') { PMA_SetComment($db, '', '(db_comment)', $comment); } /** * Prepares the tables list if the user where not redirected to this script * because there is no table in the database ($is_info is true) */ if (empty($is_info)) { require './libraries/db_common.inc.php'; $url_query .= '&goto=db_operations.php'; // Gets the database structure $sub_part = '_structure'; require './libraries/db_info.inc.php'; echo "\n"; } if (PMA_MYSQL_INT_VERSION >= 40101) { $db_collation = PMA_getDbCollation($db); } if (PMA_MYSQL_INT_VERSION < 50002 || (PMA_MYSQL_INT_VERSION >= 50002 && $db != 'information_schema')) { $is_information_schema = false; } else { $is_information_schema = true; } if (!$is_information_schema) { require './libraries/display_create_table.lib.php'; if ($cfgRelation['commwork']) { /** * database comment */ ?>
'; } echo $strDBComment; $comment = PMA_getComments($db); ?>
' . "\n"; } ?>
'; } echo $strDBRename . ':'; ?> = XYYZZ) { // echo 'RENAME DATABASE'; //} else { echo 'INSERT INTO ... SELECT'; //} echo ')'; ?>
' . "\n"; } echo '' . "\n"; echo PMA_generate_common_hidden_inputs($db); ?>
'; } echo $strDBCopy . ':'; if (PMA_MYSQL_INT_VERSION >= 50000) { $drop_clause = 'DROP TABLE / DROP VIEW'; } else { $drop_clause = 'DROP TABLE'; } ?>







style="vertical-align: middle" />
= 40101) { // MySQL supports setting default charsets / collations for databases since // version 4.1.1. echo '
' . "\n" . PMA_generate_common_hidden_inputs($db, $table) . '
' . "\n" . ' '; if ($cfg['PropertiesIconic']) { echo ''; } echo ' ' . "\n" . ' ' . "\n" . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', 'select_db_collation', $db_collation, false, 3) . ' ' . "\n" . '
' . "\n" . '
' . "\n"; } if ($num_tables > 0 && !$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == false) { /* Show error if user has configured something, notice elsewhere */ if (!empty($cfg['Servers'][$server]['pmadb'])) { echo '

' . $strError . '

'; } else { echo '
'; } printf($strRelationNotWorking, '', ''); echo '
'; } // end if } // end if (!$is_information_schema) // not sure about displaying the PDF dialog in case db is information_schema if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?> 0) { ?>
'; } echo $strDisplayPDF; ?>:






'; if ($cfg['PropertiesIconic']) { echo ''; } echo $strEditPDFPages . ''; } // end if /** * Displays the footer */ require_once './libraries/footer.inc.php'; ?>