From 720f5fc8a49015de79eaac943de9416779828df1 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Thu, 5 Jul 2007 04:39:15 +0000 Subject: [PATCH] Restructure indexes git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@28 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- functions.inc.php | 22 ++++++++++------------ indexes.inc.php | 18 ++++++++---------- table.inc.php | 8 +++----- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/functions.inc.php b/functions.inc.php index a048114e..6c5cf088 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -56,8 +56,8 @@ function indexes($table) { $return = array(); $result = mysql_query("SHOW INDEX FROM " . idf_escape($table)); while ($row = mysql_fetch_assoc($result)) { - $type = ($row["Key_name"] == "PRIMARY" ? "PRIMARY" : ($row["Index_type"] == "FULLTEXT" ? "FULLTEXT" : ($row["Non_unique"] ? "INDEX" : "UNIQUE"))); - $return[$type][$row["Key_name"]][$row["Seq_in_index"]] = $row["Column_name"]; + $return[$row["Key_name"]]["type"] = ($row["Key_name"] == "PRIMARY" ? "PRIMARY" : ($row["Index_type"] == "FULLTEXT" ? "FULLTEXT" : ($row["Non_unique"] ? "INDEX" : "UNIQUE"))); + $return[$row["Key_name"]]["columns"][$row["Seq_in_index"]] = $row["Column_name"]; } mysql_free_result($result); return $return; @@ -79,18 +79,16 @@ function foreign_keys($table) { } function unique_idf($row, $indexes) { - foreach ($indexes as $type => $index) { - if ($type == "PRIMARY" || $type == "UNIQUE") { - foreach ($index as $columns) { - $return = array(); - foreach ($columns as $key) { - if (!isset($row[$key])) { - continue 2; - } - $return[] = urlencode("where[$key]") . "=" . urlencode($row[$key]); + foreach ($indexes as $index) { + if ($index["type"] == "PRIMARY" || $index["type"] == "UNIQUE") { + $return = array(); + foreach ($index["columns"] as $key) { + if (!isset($row[$key])) { + continue 2; } - return $return; + $return[] = urlencode("where[$key]") . "=" . urlencode($row[$key]); } + return $return; } } $return = array(); diff --git a/indexes.inc.php b/indexes.inc.php index 4e741249..6f96806a 100644 --- a/indexes.inc.php +++ b/indexes.inc.php @@ -18,17 +18,15 @@ if ($_POST) { $index) { - foreach ($index as $columns) { - echo ""; - sort($columns); - foreach ($columns as $i => $column) { - echo ""; - } - echo ""; - echo "\n"; - $j++; +foreach ($row["indexes"] as $index) { + echo ""; + sort($index["columns"]); + foreach ($index["columns"] as $i => $column) { + echo ""; } + echo ""; + echo "\n"; + $j++; } //! JavaScript for adding more indexes and columns ?> diff --git a/table.inc.php b/table.inc.php index f1241cd6..b29ffb7c 100644 --- a/table.inc.php +++ b/table.inc.php @@ -15,11 +15,9 @@ echo "

" . lang('Indexes') . "

\n"; $indexes = indexes($_GET["table"]); if ($indexes) { echo "\n"; - foreach ($indexes as $type => $index) { - foreach ($index as $columns) { - sort($columns); - echo "\n"; - } + foreach ($indexes as $index) { + sort($index["columns"]); + echo "\n"; } echo "
$type" . implode(", ", $columns) . "
$index[type]" . implode(", ", $index["columns"]) . "
\n"; }