block table rename if newname empty

This commit is contained in:
Steve Alberty
2001-07-17 09:59:25 +00:00
parent 1fee1b72dc
commit eece3b3462
3 changed files with 37 additions and 24 deletions

View File

@@ -5,6 +5,9 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2001-07-17 Steve Alberty <alberty@neptunlabs.de>
* tbl_addfield.php3: add trouble detection if insert field failed
* tbl_rename.php3,tbl_copy.php3: block table rename if newname empty
2001-07-16 Marc Delisle <lem9@users.sourceforge.net> 2001-07-16 Marc Delisle <lem9@users.sourceforge.net>
* tbl_change.php3, bug 441689, "Insert as new row" was not copying blobs. * tbl_change.php3, bug 441689, "Insert as new row" was not copying blobs.

View File

@@ -16,29 +16,30 @@ function my_handler($sql_insert)
$sql_query = $sql_insert; $sql_query = $sql_insert;
} }
$sql_structure = get_table_def($db, $table, "\n"); if (isset($new_name)) $new_name=trim($new_name); // Cleanup to suppress '' tables
// speedup copy table - staybyte - 22. Juni 2001 if (isset($new_name) && $new_name!=""){
if(MYSQL_MAJOR_VERSION >= "3.23"){ $sql_structure = get_table_def($db, $table, "\n");
$sql_structure = ereg_replace("CREATE TABLE `$table`", "CREATE TABLE `$new_name`", $sql_structure); // speedup copy table - staybyte - 22. Juni 2001
$result = mysql_query($sql_structure) or mysql_die(); if(MYSQL_MAJOR_VERSION >= "3.23"){
if($what == "data"){ $sql_structure = ereg_replace("CREATE TABLE `$table`", "CREATE TABLE `$new_name`", $sql_structure);
$query="INSERT INTO $new_name SELECT * FROM $table"; $result = mysql_query($sql_structure) or mysql_die();
$result = mysql_query($query) or mysql_die(); if($what == "data"){
$query="INSERT INTO $new_name SELECT * FROM $table";
$result = mysql_query($query) or mysql_die();
}
}
else{
$sql_structure = ereg_replace("CREATE TABLE $table", "CREATE TABLE $new_name", $sql_structure);
$result = mysql_query($sql_structure) or mysql_die();
} }
} }
else{ else mysql_die($strTableEmpty);
$sql_structure = ereg_replace("CREATE TABLE $table", "CREATE TABLE $new_name", $sql_structure);
$result = mysql_query($sql_structure) or mysql_die();
}
if (isset($sql_query)) if (isset($sql_query))
$sql_query .= "\n$sql_structure"; $sql_query .= "\n$sql_structure";
else else
$sql_query = "$sql_structure"; $sql_query = "$sql_structure";
//$sql_query .= "\n$sql_structure";
if(MYSQL_MAJOR_VERSION < "3.23" && $what == "data") get_table_content($db, $table, "my_handler"); if(MYSQL_MAJOR_VERSION < "3.23" && $what == "data") get_table_content($db, $table, "my_handler");
eval("\$message = \"$strCopyTableOK\";"); eval("\$message = \"$strCopyTableOK\";");

View File

@@ -3,16 +3,25 @@
require("./grab_globals.inc.php3"); require("./grab_globals.inc.php3");
$old_name = $table; if (isset($new_name)) $new_name=trim($new_name); // Cleanup to suppress '' tables
$table = $new_name; if (isset($new_name) && $new_name!=""){
require("./header.inc.php3");
$old_name = $table;
$table = $new_name;
include("./header.inc.php3");
mysql_select_db($db);
$result = mysql_query("ALTER TABLE $old_name RENAME $new_name") or mysql_die();
$table = $old_name;
eval("\$message = \"$strRenameTableOK\";");
$table = $new_name;
}
else{
include("./header.inc.php3");
mysql_die($strTableEmpty);
}
mysql_select_db($db);
$result = mysql_query("ALTER TABLE $old_name RENAME $new_name") or mysql_die();
$table = $old_name;
eval("\$message = \"$strRenameTableOK\";");
$table = $new_name;
require("./tbl_properties.php3"); require("./tbl_properties.php3");
?> ?>