optimized the "DROP FIELD" case

This commit is contained in:
Loïc Chapeaux
2001-09-09 17:05:32 +00:00
parent 37b7c5ece7
commit ec78d60553

View File

@@ -51,11 +51,20 @@ if (!empty($submit_mult)
break; break;
case 'drop_fld': case 'drop_fld':
$full_query .= 'ALTER TABLE ' if ($full_query == '') {
. backquote(htmlspecialchars($table)) $full_query .= 'ALTER TABLE '
. ' DROP ' . backquote(htmlspecialchars($table))
. backquote(htmlspecialchars(urldecode($selected[$i]))) . '<br />&nbsp;&nbsp;DROP '
. ';<br />'; . backquote(htmlspecialchars(urldecode($selected[$i])))
. ',';
} else {
$full_query .= '<br />&nbsp;&nbsp;DROP '
. backquote(htmlspecialchars(urldecode($selected[$i])))
. ',';
}
if ($i == $selected_cnt-1) {
$full_query = ereg_replace(',$', ';<br />', $full_query);
}
break; break;
} // end switch } // end switch
} }
@@ -118,20 +127,39 @@ else if ((get_magic_quotes_gpc() && stripslashes($btnDrop) == $strYes)
break; break;
case 'drop_fld': case 'drop_fld':
$a_query = 'ALTER TABLE ' if ($sql_query == '') {
. backquote($table) $sql_query .= 'ALTER TABLE '
. ' DROP ' . backquote($table)
. backquote(urldecode($selected[$i])); . ' 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
$sql_query .= $a_query . ';' . "\n";
if ($query_type != 'drop_db') { // All "drop field" statements will be run at once below
mysql_select_db($db); if ($query_type != 'drop_fld') {
} $sql_query .= $a_query . ';' . "\n";
$result = @mysql_query($a_query) or mysql_die('', $a_query, FALSE);
if ($query_type != 'drop_db') {
mysql_select_db($db);
}
$result = @mysql_query($a_query) or mysql_die('', $a_query, FALSE);
} // end if
} // end for } // end for
if ($query_type == 'drop_fld') {
mysql_select_db($db);
$result = @mysql_query($sql_query) or mysql_die('', '', FALSE);
}
show_message($strSuccess); show_message($strSuccess);
} }