Link to original table in EXPLAIN of SELECT * FROM table t
This commit is contained in:
parent
77ec05d50b
commit
48df7aa1c9
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue