diff --git a/functions.inc.php b/functions.inc.php index 6c5cf088..dba5cdb7 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -23,7 +23,7 @@ function optionlist($options, $selected = array(), $not_vals = false) { $return .= ''; } foreach ((is_array($v) ? $v : array($k => $v)) as $key => $val) { - $checked = in_array(($not_vals ? $val : $key), (array) $selected); + $checked = in_array(($not_vals ? $val : $key), (array) $selected, true); $return .= '' . htmlspecialchars($val) . ''; } if (is_array($v)) { diff --git a/indexes.inc.php b/indexes.inc.php index 6f96806a..f43f8bb0 100644 --- a/indexes.inc.php +++ b/indexes.inc.php @@ -1,6 +1,36 @@ $existing) { + if ($index["type"] == $existing["type"] && $existing["columns"] == $columns) { + unset($indexes[$name]); + continue 2; + } + } + $alter[] = "ADD $index[type]" . ($index["type"] == "PRIMARY" ? " KEY" : "") . " (" . implode(", ", array_map('idf_escape', $columns)) . ")"; + } + } + } + foreach ($indexes as $name => $existing) { + $alter[] = "DROP INDEX " . idf_escape($name); + } + if (!$alter || mysql_query("ALTER TABLE " . idf_escape($_GET["indexes"]) . " " . implode(", ", $alter))) { + redirect($SELF . "table=" . urlencode($_GET["indexes"]), ($alter ? lang('Indexes has been altered.') : null)); + } + $error = mysql_error(); } page_header(lang('Indexes') . ': ' . htmlspecialchars($_GET["indexes"])); @@ -10,17 +40,16 @@ if ($_POST) { echo "

" . lang('Unable to operate indexes') . ": " . htmlspecialchars($error) . "

\n"; $row = $_POST; } else { - $row = array("indexes" => indexes($_GET["indexes"])); + $row = array("indexes" => $indexes); } ?>
"; - sort($index["columns"]); + ksort($index["columns"]); foreach ($index["columns"] as $i => $column) { echo ""; } diff --git a/table.inc.php b/table.inc.php index b29ffb7c..b560d57e 100644 --- a/table.inc.php +++ b/table.inc.php @@ -16,7 +16,7 @@ $indexes = indexes($_GET["table"]); if ($indexes) { echo "\n"; foreach ($indexes as $index) { - sort($index["columns"]); + ksort($index["columns"]); echo "\n"; } echo "
$index[type]" . implode(", ", $index["columns"]) . "
\n";