$column) { if ($column != "") { $length = $index["lengths"][$key]; $desc = $index["descs"][$key]; $set[] = idf_escape($column) . ($length ? "(" . (+$length) . ")" : "") . ($desc ? " DESC" : ""); $columns[] = $column; $lengths[] = ($length ? $length : null); $descs[] = $desc; } } if ($columns) { $existing = $indexes[$name]; if ($existing) { ksort($existing["columns"]); ksort($existing["lengths"]); ksort($existing["descs"]); if ($index["type"] == $existing["type"] && array_values($existing["columns"]) === $columns && (!$existing["lengths"] || array_values($existing["lengths"]) === $lengths) && array_values($existing["descs"]) === $descs ) { // skip existing index unset($indexes[$name]); continue; } } $alter[] = array($index["type"], $name, $set); } } } // drop removed indexes foreach ($indexes as $name => $existing) { $alter[] = array($existing["type"], $name, "DROP"); } if (!$alter) { redirect(ME . "table=" . urlencode($TABLE)); } queries_redirect(ME . "table=" . urlencode($TABLE), lang('Indexes have been altered.'), alter_indexes($TABLE, $alter)); } page_header(lang('Indexes'), $error, array("table" => $TABLE), h($TABLE)); $fields = array_keys(fields($TABLE)); if ($_POST["add"]) { foreach ($row["indexes"] as $key => $index) { if ($index["columns"][count($index["columns"])] != "") { $row["indexes"][$key]["columns"][] = ""; } } $index = end($row["indexes"]); if ($index["type"] || array_filter($index["columns"], 'strlen')) { $row["indexes"][] = array("columns" => array(1 => "")); } } if (!$row) { foreach ($indexes as $key => $index) { $indexes[$key]["name"] = $key; $indexes[$key]["columns"][] = ""; } $indexes[] = array("columns" => array(1 => "")); $row["indexes"] = $indexes; } ?>
PRIMARY"; foreach ($primary["columns"] as $key => $column) { echo select_input(" disabled", $fields, $column); echo " "; } echo "\n"; } $j = 1; foreach ($row["indexes"] as $index) { if (!$_POST["drop_col"] || $j != key($_POST["drop_col"])) { echo "
" . html_select("indexes[$j][type]", array(-1 => "") + $index_types, $index["type"], ($j == count($row["indexes"]) ? "indexesAddRow.call(this);" : 1), "label-type"); echo ""; ksort($index["columns"]); $i = 1; foreach ($index["columns"] as $key => $column) { echo "" . select_input( " name='indexes[$j][columns][$i]' title='" . lang('Column') . "'", ($fields ? array_combine($fields, $fields) : $fields), $column, "partial(" . ($i == count($index["columns"]) ? "indexesAddColumn" : "indexesChangeColumn") . ", '" . js_escape($jush == "sql" ? "" : $_GET["indexes"] . "_") . "')" ); echo ($jush == "sql" || $jush == "mssql" ? "" : ""); echo (support("descidx") ? checkbox("indexes[$j][descs][$i]", 1, $index["descs"][$key], lang('descending')) : ""); echo " "; $i++; } echo "\n"; echo "" . script("qsl('input').onclick = partial(editingRemoveRow, 'indexes\$1[type]');"); } $j++; } ?>