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');
13 PMA_checkParameters(array('db','table'));
16 * Defines the url to return to in case of error in a sql statement
18 $err_url = 'tbl_properties.php3?' . PMA_generate_common_url($db, $table);
22 * A new name has been submitted -> do the work
24 if (isset($new_name) && trim($new_name) != '') {
28 // Ensure the target is valid
29 if (count($dblist) > 0 && PMA_isInto($db, $dblist) == -1) {
32 if (PMA_MYSQL_INT_VERSION
< 32306) {
33 PMA_checkReservedWords($new_name, $err_url);
36 include('./header.inc.php3');
37 PMA_mysql_select_db($db);
38 $sql_query = 'ALTER TABLE ' . PMA_backquote($old_name) . ' RENAME ' . PMA_backquote($new_name);
39 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
40 $message = sprintf($strRenameTableOK, htmlspecialchars($old_name), htmlspecialchars($table));
43 // garvin: Move old entries from comments to new table
44 include('./libraries/relation.lib.php3');
45 $cfgRelation = PMA_getRelationsParam();
46 if ($cfgRelation['commwork']) {
47 $remove_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info'])
48 . ' SET table_name = \'' . PMA_sqlAddslashes($table) . '\''
49 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
50 . ' AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';
51 $rmv_rs = PMA_query_as_cu($remove_query);
55 if ($cfgRelation['displaywork']) {
56 $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_info'])
57 . ' SET table_name = \'' . PMA_sqlAddslashes($table) . '\''
58 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
59 . ' AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';
60 $tb_rs = PMA_query_as_cu($table_query);
65 if ($cfgRelation['relwork']) {
66 $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation'])
67 . ' SET foreign_table = \'' . PMA_sqlAddslashes($table) . '\''
68 . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
69 . ' AND foreign_table = \'' . PMA_sqlAddslashes($old_name) . '\'';
70 $tb_rs = PMA_query_as_cu($table_query);
74 $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation'])
75 . ' SET master_table = \'' . PMA_sqlAddslashes($table) . '\''
76 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
77 . ' AND master_table = \'' . PMA_sqlAddslashes($old_name) . '\'';
78 $tb_rs = PMA_query_as_cu($table_query);
83 if ($cfgRelation['pdfwork']) {
84 $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_coords'])
85 . ' SET table_name = \'' . PMA_sqlAddslashes($table) . '\''
86 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
87 . ' AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';
88 $tb_rs = PMA_query_as_cu($table_query);
97 * No new name for the table!
100 include('./header.inc.php3');
101 PMA_mysqlDie($strTableEmpty, '', '', $err_url);
106 * Back to the calling script
108 require('./tbl_properties_operations.php3');