home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / phptriad / phptriad2-2-1.exe / htdocs / phpmyadmin / tbl_rename.php < prev    next >
PHP Script  |  2002-01-06  |  1KB  |  64 lines

  1. <?php
  2. /* $Id: tbl_rename.php,v 1.16 2001/11/23 01:03:20 loic1 Exp $ */
  3.  
  4.  
  5. /**
  6.  * Gets some core libraries
  7.  */
  8. require('./libraries/grab_globals.lib.php');
  9. $js_to_run = 'functions.js';
  10. require('./libraries/common.lib.php');
  11.  
  12.  
  13. /**
  14.  * Defines the url to return to in case of error in a sql statement
  15.  */
  16. $err_url = 'tbl_properties.php'
  17.          . '?lang=' . $lang
  18.          . '&server=' . $server
  19.          . '&db=' . urlencode($db)
  20.          . '&table=' . urlencode($table);
  21.  
  22.  
  23. /**
  24.  * A new name has been submitted -> do the work
  25.  */
  26. if (isset($new_name) && trim($new_name) != '') { 
  27.     $old_name     = $table;
  28.     $table        = $new_name;
  29.     if (get_magic_quotes_gpc()) {
  30.         $new_name = stripslashes($new_name);
  31.     }
  32.  
  33.     // Ensure the target is valid
  34.     if (count($dblist) > 0 && PMA_isInto($db, $dblist) == -1) {
  35.         exit();
  36.     }
  37.     if (PMA_MYSQL_INT_VERSION < 32306) {
  38.         PMA_checkReservedWords($new_name, $err_url);
  39.     }
  40.  
  41.     include('./header.inc.php');
  42.     mysql_select_db($db);
  43.     $sql_query = 'ALTER TABLE ' . PMA_backquote($old_name) . ' RENAME ' . PMA_backquote($new_name);
  44.     $result    = mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
  45.     $message   = sprintf($strRenameTableOK, $old_name, $table);
  46.     $reload    = 1;
  47.  
  48.  
  49. /**
  50.  * No new name for the table!
  51.  */
  52. else { 
  53.     include('./header.inc.php');
  54.     PMA_mysqlDie($strTableEmpty, '', '', $err_url); 
  55.  
  56.  
  57. /**
  58.  * Back to the calling script
  59.  */
  60. require('./tbl_properties.php');
  61. ?>
  62.