Documentation TYPO3 par Ameos |
00001 <?php 00002 /* $Id: tbl_rename.php,v 2.5 2004/01/22 02:13:47 rabus Exp $ */ 00003 // vim: expandtab sw=4 ts=4 sts=4: 00004 00005 00009 require_once('./libraries/grab_globals.lib.php'); 00010 $js_to_run = 'functions.js'; 00011 require_once('./libraries/common.lib.php'); 00012 00013 PMA_checkParameters(array('db','table')); 00014 00018 $err_url = 'tbl_properties.php?' . PMA_generate_common_url($db, $table); 00019 00020 00024 if (isset($new_name) && trim($new_name) != '' && strpos($new_name,'.') === FALSE) { 00025 $old_name = $table; 00026 $table = $new_name; 00027 00028 // Ensure the target is valid 00029 if (count($dblist) > 0 && PMA_isInto($db, $dblist) == -1) { 00030 exit(); 00031 } 00032 00033 require_once('./header.inc.php'); 00034 PMA_DBI_select_db($db); 00035 $sql_query = 'ALTER TABLE ' . PMA_backquote($old_name) . ' RENAME ' . PMA_backquote($new_name) . ';'; 00036 $result = PMA_DBI_query($sql_query); 00037 $message = sprintf($strRenameTableOK, htmlspecialchars($old_name), htmlspecialchars($table)); 00038 $reload = 1; 00039 00040 // garvin: Move old entries from comments to new table 00041 require_once('./libraries/relation.lib.php'); 00042 $cfgRelation = PMA_getRelationsParam(); 00043 if ($cfgRelation['commwork']) { 00044 $remove_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info']) 00045 . ' SET table_name = \'' . PMA_sqlAddslashes($table) . '\'' 00046 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' 00047 . ' AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\''; 00048 $rmv_rs = PMA_query_as_cu($remove_query); 00049 unset($rmv_query); 00050 } 00051 00052 if ($cfgRelation['displaywork']) { 00053 $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_info']) 00054 . ' SET table_name = \'' . PMA_sqlAddslashes($table) . '\'' 00055 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' 00056 . ' AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\''; 00057 $tb_rs = PMA_query_as_cu($table_query); 00058 unset($table_query); 00059 unset($tb_rs); 00060 } 00061 00062 if ($cfgRelation['relwork']) { 00063 $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation']) 00064 . ' SET foreign_table = \'' . PMA_sqlAddslashes($table) . '\'' 00065 . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'' 00066 . ' AND foreign_table = \'' . PMA_sqlAddslashes($old_name) . '\''; 00067 $tb_rs = PMA_query_as_cu($table_query); 00068 unset($table_query); 00069 unset($tb_rs); 00070 00071 $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation']) 00072 . ' SET master_table = \'' . PMA_sqlAddslashes($table) . '\'' 00073 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' 00074 . ' AND master_table = \'' . PMA_sqlAddslashes($old_name) . '\''; 00075 $tb_rs = PMA_query_as_cu($table_query); 00076 unset($table_query); 00077 unset($tb_rs); 00078 } 00079 00080 if ($cfgRelation['pdfwork']) { 00081 $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_coords']) 00082 . ' SET table_name = \'' . PMA_sqlAddslashes($table) . '\'' 00083 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' 00084 . ' AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\''; 00085 $tb_rs = PMA_query_as_cu($table_query); 00086 unset($table_query); 00087 unset($tb_rs); 00088 } 00089 00090 } 00091 00092 00096 else { 00097 require_once('./header.inc.php'); 00098 if (strpos($new_name,'.') === FALSE) { 00099 PMA_mysqlDie($strTableEmpty, '', '', $err_url); 00100 } else { 00101 PMA_mysqlDie($strError . ': ' . $new_name, '', '', $err_url); 00102 } 00103 } 00104 00105 00109 require('./tbl_properties_operations.php'); 00110 ?>