From 48df7aa1c9cb23b9e3e53e5808b09f8f257f0433 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sun, 15 Apr 2012 10:53:40 -0700 Subject: [PATCH] Link to original table in EXPLAIN of SELECT * FROM table t --- adminer/include/editing.inc.php | 9 +++++++-- adminer/sql.inc.php | 4 ++-- changes.txt | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index e104e119..b2b35d1d 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -3,14 +3,16 @@ * @param Min_Result * @param Min_DB connection to examine indexes * @param string base link for fields +* @param array * @return null */ -function select($result, $connection2 = null, $href = "") { +function select($result, $connection2 = null, $href = "", $orgtables = array()) { $links = array(); // colno => orgtable - create links from these columns $indexes = array(); // orgtable => array(column => colno) - primary keys $columns = array(); // orgtable => array(column => ) - not selected columns in primary key $blobs = array(); // colno => bool - display bytes for blobs $types = array(); // colno => type - display char in + $return = array(); // table => orgtable - mapping to use in EXPLAIN odd(''); // reset odd for each result for ($i=0; $row = $result->fetch_row(); $i++) { if (!$i) { @@ -21,6 +23,7 @@ function select($result, $connection2 = null, $href = "") { $name = $field->name; $orgtable = $field->orgtable; $orgname = $field->orgname; + $return[$field->table] = $orgtable; if ($href) { // MySQL EXPLAIN $links[$j] = ($name == "table" ? "table=" : ($name == "possible_keys" ? "indexes=" : null)); } elseif ($orgtable != "") { @@ -66,7 +69,8 @@ function select($result, $connection2 = null, $href = "") { } if (isset($links[$key]) && !$columns[$links[$key]]) { if ($href) { // MySQL EXPLAIN - $link = $links[$key] . urlencode($row[array_search("table=", $links)]); + $table = $row[array_search("table=", $links)]; + $link = $links[$key] . urlencode($orgtables[$table] != "" ? $orgtables[$table] : $table); } else { $link = "edit=" . urlencode($links[$key]); foreach ($indexes[$links[$key]] as $col => $j) { @@ -79,6 +83,7 @@ function select($result, $connection2 = null, $href = "") { } } echo ($i ? "" : "

" . lang('No rows.')) . "\n"; + return $return; } /** Get referencable tables with single column primary key except self diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index a3b33f2d..fe842863 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -109,7 +109,7 @@ if (!$error && $_POST) { break 2; } } elseif (is_object($result)) { - select($result, $connection2); + $orgtables = select($result, $connection2); if (!$_POST["only_errors"]) { echo "

\n"; echo "

" . ($result->num_rows ? lang('%d row(s)', $result->num_rows) : "") . $time; @@ -124,7 +124,7 @@ if (!$error && $_POST) { $id = "explain-$commands"; echo ", EXPLAIN$export"; echo "

\n"; } else { echo $export; diff --git a/changes.txt b/changes.txt index e16f59ec..393d079a 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,6 @@ Adminer 3.4.0-dev: Print current time next to executed SQL queries +Link to original table in EXPLAIN of SELECT * FROM table t Replace JSMin by better JavaScript minifier Ukrainian translation