re-enabled the ability to copy a table to another database (bug #456434).
Need to be tested with MySQL < 3.23 releases.
This commit is contained in:
@@ -16,6 +16,9 @@ $Source$
|
||||
name or not at the top of the page.
|
||||
* tbl_select.php3: the script to returns to was hard coded, now it's the
|
||||
one that calls tbl_select.php3.
|
||||
* tbl_copy.php3; tbl_properties.php3: re-enabled the ability to copy a
|
||||
table to another database (bug #456434). Need to be tested with
|
||||
MySQL < 3.23 releases.
|
||||
|
||||
2001-08-28 Lo<4C>c Chapeaux <lolo@phpheaven.net>
|
||||
* lang/galician.inc.php3, select_lang.inc.php3: new Galician lang thanks to
|
||||
|
@@ -9,15 +9,15 @@
|
||||
*
|
||||
* @global string the database name
|
||||
* @global string the original table name
|
||||
* @global string the target table name
|
||||
* @global string the target database and table names
|
||||
* @global string the sql query used to copy the data
|
||||
*/
|
||||
function my_handler($sql_insert = '')
|
||||
{
|
||||
global $db, $table, $new_name;
|
||||
global $db, $table, $target;
|
||||
global $sql_insert_data;
|
||||
|
||||
$sql_insert = eregi_replace('INSERT INTO (`?)' . $table . '(`?)', 'INSERT INTO ' . backquote($new_name), $sql_insert);
|
||||
$sql_insert = eregi_replace('INSERT INTO (`?)' . $table . '(`?)', 'INSERT INTO ' . $target, $sql_insert);
|
||||
$result = mysql_query($sql_insert) or mysql_die('', $sql_insert);
|
||||
|
||||
$sql_insert_data .= $sql_insert . ';' . "\n";
|
||||
@@ -44,8 +44,19 @@ if (isset($new_name) && trim($new_name) != '') {
|
||||
$use_backquotes = 1;
|
||||
$asfile = 1;
|
||||
|
||||
if (get_magic_quotes_gpc()) {
|
||||
if (!empty($target_db)) {
|
||||
$target_db = stripslashes($target_db);
|
||||
} else {
|
||||
$target_db = stripslashes($db);
|
||||
}
|
||||
$new_name = stripslashes($new_name);
|
||||
}
|
||||
$source = backquote($db) . '.' . backquote($table);
|
||||
$target = backquote($target_db) . '.' . backquote($new_name);
|
||||
|
||||
$sql_structure = get_table_def($db, $table, "\n");
|
||||
$sql_structure = eregi_replace('^CREATE TABLE (`?)' . $table . '(`?)', 'CREATE TABLE ' . backquote($new_name), $sql_structure);
|
||||
$sql_structure = eregi_replace('^CREATE TABLE (`?)' . $table . '(`?)', 'CREATE TABLE ' . $target, $sql_structure);
|
||||
$result = mysql_query($sql_structure) or mysql_die('', $sql_structure);
|
||||
if (isset($sql_query)) {
|
||||
$sql_query .= "\n" . $sql_structure . ';';
|
||||
@@ -57,7 +68,7 @@ if (isset($new_name) && trim($new_name) != '') {
|
||||
if ($result != FALSE && $what == 'data') {
|
||||
// speedup copy table - staybyte - 22. Juni 2001
|
||||
if (MYSQL_INT_VERSION >= 32300) {
|
||||
$sql_insert_data = 'INSERT INTO ' . backquote($new_name) . ' SELECT * FROM ' . backquote($table);
|
||||
$sql_insert_data = 'INSERT INTO ' . $target . ' SELECT * FROM ' . backquote($table);
|
||||
$result = mysql_query($sql_insert_data) or mysql_die('', $sql_insert_data);
|
||||
} // end MySQL >= 3.23
|
||||
else {
|
||||
@@ -67,7 +78,7 @@ if (isset($new_name) && trim($new_name) != '') {
|
||||
$sql_query .= "\n\n" . $sql_insert_data;
|
||||
}
|
||||
|
||||
$message = sprintf($strCopyTableOK, $table, $new_name);
|
||||
$message = sprintf($strCopyTableOK, $source, $target);
|
||||
$reload = 'true';
|
||||
} // end is target table name
|
||||
|
||||
|
@@ -808,12 +808,14 @@ echo "\n";
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<?php echo $strCopyTable; ?> :
|
||||
<?php echo $strCopyTable . ' (' . $strDatabase . '<b>.</b>' . trim($strTable) . ')'; ?> :
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="text" style="width: 100%" name="new_name" />
|
||||
<input type="text" size="10" name="target_db" value="<?php echo $db; ?>" />
|
||||
<b>.</b>
|
||||
<input type="text" size="25" name="new_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
Reference in New Issue
Block a user