]> git.joonet.de Git - adminer.git/commitdiff
Link to original table in EXPLAIN of SELECT * FROM table t
authorJakub Vrana <jakub@vrana.cz>
Sun, 15 Apr 2012 17:53:40 +0000 (10:53 -0700)
committerJakub Vrana <jakub@vrana.cz>
Sun, 15 Apr 2012 17:53:40 +0000 (10:53 -0700)
adminer/include/editing.inc.php
adminer/sql.inc.php
changes.txt

index e104e119310c04ec076351443919773fa3538515..b2b35d1df61af3374448de33c38f0705e2367a55 100644 (file)
@@ -3,14 +3,16 @@
 * @param Min_Result
 * @param Min_DB connection to examine indexes
 * @param string base link for <th> 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 <code>
+       $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 ? "</table>" : "<p class='message'>" . lang('No rows.')) . "\n";
+       return $return;
 }
 
 /** Get referencable tables with single column primary key except self
index a3b33f2d11ea6a12ef8afc5231fd2b45b39a2717..fe842863c39e8dc6d847bc60da88004b3b9fbb3e 100644 (file)
@@ -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 "<form action='' method='post'>\n";
                                                                        echo "<p>" . ($result->num_rows ? lang('%d row(s)', $result->num_rows) : "") . $time;
@@ -124,7 +124,7 @@ if (!$error && $_POST) {
                                                                                $id = "explain-$commands";
                                                                                echo ", <a href='#$id' onclick=\"return !toggle('$id');\">EXPLAIN</a>$export";
                                                                                echo "<div id='$id' class='hidden'>\n";
-                                                                               select($explain, $connection2, ($jush == "sql" ? "http://dev.mysql.com/doc/refman/" . substr($connection->server_info, 0, 3) . "/en/explain-output.html#explain_" : ""));
+                                                                               select($explain, $connection2, ($jush == "sql" ? "http://dev.mysql.com/doc/refman/" . substr($connection->server_info, 0, 3) . "/en/explain-output.html#explain_" : ""), $orgtables);
                                                                                echo "</div>\n";
                                                                        } else {
                                                                                echo $export;
index e16f59ec000bec9a44da031a50b2aee66f1bdf58..393d079a928021e7f8bd2ee82c573c7ad04a9887 100644 (file)
@@ -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