$column) { if (strlen($column)) { $length = $index["lengths"][$key]; $set[] = idf_escape($column) . ($length ? "(" . intval($length) . ")" : ""); $columns[count($columns) + 1] = $column; $lengths[count($lengths) + 1] = ($length ? $length : null); } } if ($columns) { foreach ($indexes as $name => $existing) { if ($index["type"] == $existing["type"] && $existing["columns"] === $columns && $existing["lengths"] === $lengths) { unset($indexes[$name]); continue 2; } } $alter[] = "ADD $index[type]" . ($index["type"] == "PRIMARY" ? " KEY" : "") . " (" . implode(", ", $set) . ")"; } } } 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"])); $fields = array_keys(fields($_GET["indexes"])); if ($_POST) { $row = $_POST; if (!$_POST["add"]) { echo "

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

\n"; } else { foreach ($row["indexes"] as $key => $index) { if (strlen($index["columns"][count($index["columns"])])) { $row["indexes"][$key]["columns"][] = ""; } } $index = $row["indexes"][count($row["indexes"]) - 1]; if ($index["type"] || array_filter($index["columns"], 'strlen') || array_filter($index["columns"], 'length')) { $row["indexes"][] = array("columns" => array(1 => "")); } } } else { $row = array("indexes" => $indexes); foreach ($row["indexes"] as $key => $index) { $row["indexes"][$key]["columns"][] = ""; } $row["indexes"][] = array("columns" => array(1 => "")); } ?>
\n"; $j++; } //! JavaScript for adding more indexes and columns ?>
"; ksort($index["columns"]); foreach ($index["columns"] as $i => $column) { echo ""; echo "\n"; } echo "