optimized a bit the SQL statements

This commit is contained in:
Loïc Chapeaux
2001-09-22 15:03:05 +00:00
parent 178b046b28
commit 6f176fae09

View File

@@ -39,9 +39,9 @@ if (!empty($submit_mult)
break; break;
case 'drop_tbl': case 'drop_tbl':
$full_query .= 'DROP TABLE ' $full_query .= (empty($full_query) ? 'DROP TABLE ' : ', ')
. backquote(htmlspecialchars(urldecode($selected[$i]))) . backquote(htmlspecialchars(urldecode($selected[$i])))
. ';<br />'; . (($i == $selected_cnt - 1) ? ';<br />' : '');
break; break;
case 'empty_tbl': case 'empty_tbl':
@@ -116,8 +116,9 @@ else if ((get_magic_quotes_gpc() && stripslashes($btnDrop) == $strYes)
break; break;
case 'drop_tbl': case 'drop_tbl':
$a_query = 'DROP TABLE ' $sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ')
. backquote(urldecode($selected[$i])); . backquote(urldecode($selected[$i]))
. (($i == $selected_cnt-1) ? ';' : '');
$reload = 1; $reload = 1;
break; break;
@@ -127,25 +128,14 @@ else if ((get_magic_quotes_gpc() && stripslashes($btnDrop) == $strYes)
break; break;
case 'drop_fld': case 'drop_fld':
if ($sql_query == '') { $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . backquote($table) : ',')
$sql_query .= 'ALTER TABLE ' . ' DROP ' . backquote(urldecode($selected[$i]))
. backquote($table) . (($i == $selected_cnt-1) ? ';' : '');
. ' 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; break;
} // end switch } // end switch
// All "drop field" statements will be run at once below // All "DROP TABLE" and "DROP FIELD" statements will be run at once below
if ($query_type != 'drop_fld') { if ($query_type != 'drop_tbl' && $query_type != 'drop_fld') {
$sql_query .= $a_query . ';' . "\n"; $sql_query .= $a_query . ';' . "\n";
if ($query_type != 'drop_db') { if ($query_type != 'drop_db') {
@@ -155,7 +145,7 @@ else if ((get_magic_quotes_gpc() && stripslashes($btnDrop) == $strYes)
} // end if } // end if
} // end for } // end for
if ($query_type == 'drop_fld') { if ($query_type == 'drop_tbl' || $query_type == 'drop_fld') {
mysql_select_db($db); mysql_select_db($db);
$result = @mysql_query($sql_query) or mysql_die('', '', FALSE); $result = @mysql_query($sql_query) or mysql_die('', '', FALSE);
} }