3 // vim: expandtab sw=4 ts=4 sts=4:
7 * Gets some core libraries
9 require('./libraries/grab_globals.lib.php3');
10 $js_to_run = 'functions.js';
11 require('./libraries/common.lib.php3');
15 * Defines the url to return to in case of error in a sql statement
17 $err_url = 'tbl_properties.php3?' . PMA_generate_common_url($db, $table);
21 * A new name has been submitted -> do the work
23 if (isset($new_name) && trim($new_name) != '') {
27 // Ensure the target is valid
28 if (count($dblist) > 0 && PMA_isInto($db, $dblist) == -1) {
31 if (PMA_MYSQL_INT_VERSION
< 32306) {
32 PMA_checkReservedWords($new_name, $err_url);
35 include('./header.inc.php3');
36 PMA_mysql_select_db($db);
37 $sql_query = 'ALTER TABLE ' . PMA_backquote($old_name) . ' RENAME ' . PMA_backquote($new_name);
38 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
39 $message = sprintf($strRenameTableOK, $old_name, $table);
42 // garvin: Move old entries from comments to new table
43 include('./libraries/relation.lib.php3');
44 $cfgRelation = PMA_getRelationsParam();
45 if ($cfgRelation['commwork']) {
46 $remove_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info'])
47 . ' SET table_name = \'' . PMA_sqlAddslashes($table) . '\''
48 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
49 . ' AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';
50 $rmv_rs = PMA_query_as_cu($remove_query);
54 if ($cfgRelation['displaywork']) {
55 $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_info'])
56 . ' SET table_name = \'' . PMA_sqlAddslashes($table) . '\''
57 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
58 . ' AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';
59 $tb_rs = PMA_query_as_cu($table_query);
64 if ($cfgRelation['relwork']) {
65 $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation'])
66 . ' SET foreign_table = \'' . PMA_sqlAddslashes($table) . '\''
67 . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
68 . ' AND foreign_table = \'' . PMA_sqlAddslashes($old_name) . '\'';
69 $tb_rs = PMA_query_as_cu($table_query);
73 $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation'])
74 . ' SET master_table = \'' . PMA_sqlAddslashes($table) . '\''
75 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
76 . ' AND master_table = \'' . PMA_sqlAddslashes($old_name) . '\'';
77 $tb_rs = PMA_query_as_cu($table_query);
82 if ($cfgRelation['pdfwork']) {
83 $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_coords'])
84 . ' SET table_name = \'' . PMA_sqlAddslashes($table) . '\''
85 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
86 . ' AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';
87 $tb_rs = PMA_query_as_cu($table_query);
96 * No new name for the table!
99 include('./header.inc.php3');
100 PMA_mysqlDie($strTableEmpty, '', '', $err_url);
105 * Back to the calling script
107 require('./tbl_properties.php3');