From ec78d6055324f45528d667d55432d5c9e0c7326c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Chapeaux?= Date: Sun, 9 Sep 2001 17:05:32 +0000 Subject: [PATCH] optimized the "DROP FIELD" case --- mult_submits.inc.php3 | 56 ++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/mult_submits.inc.php3 b/mult_submits.inc.php3 index fd4611b70..c41679ce2 100644 --- a/mult_submits.inc.php3 +++ b/mult_submits.inc.php3 @@ -51,11 +51,20 @@ if (!empty($submit_mult) break; case 'drop_fld': - $full_query .= 'ALTER TABLE ' - . backquote(htmlspecialchars($table)) - . ' DROP ' - . backquote(htmlspecialchars(urldecode($selected[$i]))) - . ';
'; + if ($full_query == '') { + $full_query .= 'ALTER TABLE ' + . backquote(htmlspecialchars($table)) + . '
  DROP ' + . backquote(htmlspecialchars(urldecode($selected[$i]))) + . ','; + } else { + $full_query .= '
  DROP ' + . backquote(htmlspecialchars(urldecode($selected[$i]))) + . ','; + } + if ($i == $selected_cnt-1) { + $full_query = ereg_replace(',$', ';
', $full_query); + } break; } // end switch } @@ -118,20 +127,39 @@ else if ((get_magic_quotes_gpc() && stripslashes($btnDrop) == $strYes) break; case 'drop_fld': - $a_query = 'ALTER TABLE ' - . backquote($table) - . ' DROP ' - . backquote(urldecode($selected[$i])); + if ($sql_query == '') { + $sql_query .= 'ALTER TABLE ' + . backquote($table) + . ' DROP ' + . backquote(urldecode($selected[$i])) + . ','; + } else { + $sql_query .= ' DROP ' + . backquote(urldecode($selected[$i])) + . ','; + } + if ($i == $selected_cnt-1) { + $sql_query = ereg_replace(',$', ';', $sql_query); + } break; } // end switch - $sql_query .= $a_query . ';' . "\n"; - if ($query_type != 'drop_db') { - mysql_select_db($db); - } - $result = @mysql_query($a_query) or mysql_die('', $a_query, FALSE); + // All "drop field" statements will be run at once below + if ($query_type != 'drop_fld') { + $sql_query .= $a_query . ';' . "\n"; + + if ($query_type != 'drop_db') { + mysql_select_db($db); + } + $result = @mysql_query($a_query) or mysql_die('', $a_query, FALSE); + } // end if } // end for + if ($query_type == 'drop_fld') { + mysql_select_db($db); + $result = @mysql_query($sql_query) or mysql_die('', '', FALSE); + } + show_message($strSuccess); }