Link tables and indexes from SQL command EXPLAIN
This commit is contained in:
parent
ac8a64e88a
commit
8a9642b217
|
@ -18,9 +18,12 @@ function select($result, $connection2 = null, $href = "") {
|
||||||
echo "<thead><tr>";
|
echo "<thead><tr>";
|
||||||
for ($j=0; $j < count($row); $j++) {
|
for ($j=0; $j < count($row); $j++) {
|
||||||
$field = $result->fetch_field();
|
$field = $result->fetch_field();
|
||||||
|
$name = $field->name;
|
||||||
$orgtable = $field->orgtable;
|
$orgtable = $field->orgtable;
|
||||||
$orgname = $field->orgname;
|
$orgname = $field->orgname;
|
||||||
if ($orgtable != "") {
|
if ($href) { // MySQL EXPLAIN
|
||||||
|
$links[$j] = ($name == "table" ? "table=" : ($name == "possible_keys" ? "indexes=" : null));
|
||||||
|
} elseif ($orgtable != "") {
|
||||||
if (!isset($indexes[$orgtable])) {
|
if (!isset($indexes[$orgtable])) {
|
||||||
// find primary key in each table
|
// find primary key in each table
|
||||||
$indexes[$orgtable] = array();
|
$indexes[$orgtable] = array();
|
||||||
|
@ -42,7 +45,7 @@ function select($result, $connection2 = null, $href = "") {
|
||||||
$blobs[$j] = true;
|
$blobs[$j] = true;
|
||||||
}
|
}
|
||||||
$types[$j] = $field->type;
|
$types[$j] = $field->type;
|
||||||
$name = h($field->name);
|
$name = h($name);
|
||||||
echo "<th" . ($orgtable != "" || $field->name != $orgname ? " title='" . h(($orgtable != "" ? "$orgtable." : "") . $orgname) . "'" : "") . ">" . ($href ? "<a href='$href" . strtolower($name) . "' target='_blank' rel='noreferrer'>$name</a>" : $name);
|
echo "<th" . ($orgtable != "" || $field->name != $orgname ? " title='" . h(($orgtable != "" ? "$orgtable." : "") . $orgname) . "'" : "") . ">" . ($href ? "<a href='$href" . strtolower($name) . "' target='_blank' rel='noreferrer'>$name</a>" : $name);
|
||||||
}
|
}
|
||||||
echo "</thead>\n";
|
echo "</thead>\n";
|
||||||
|
@ -51,24 +54,26 @@ function select($result, $connection2 = null, $href = "") {
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
if (!isset($val)) {
|
if (!isset($val)) {
|
||||||
$val = "<i>NULL</i>";
|
$val = "<i>NULL</i>";
|
||||||
|
} elseif ($blobs[$key] && !is_utf8($val)) {
|
||||||
|
$val = "<i>" . lang('%d byte(s)', strlen($val)) . "</i>"; //! link to download
|
||||||
|
} elseif (!strlen($val)) { // strlen - SQLite can return int
|
||||||
|
$val = " "; // some content to print a border
|
||||||
} else {
|
} else {
|
||||||
if ($blobs[$key] && !is_utf8($val)) {
|
$val = h($val);
|
||||||
$val = "<i>" . lang('%d byte(s)', strlen($val)) . "</i>"; //! link to download
|
if ($types[$key] == 254) { // 254 - char
|
||||||
} elseif (!strlen($val)) { // strlen - SQLite can return int
|
$val = "<code>$val</code>";
|
||||||
$val = " "; // some content to print a border
|
|
||||||
} else {
|
|
||||||
$val = h($val);
|
|
||||||
if ($types[$key] == 254) { // 254 - char
|
|
||||||
$val = "<code>$val</code>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isset($links[$key]) && !$columns[$links[$key]]) {
|
}
|
||||||
|
if (isset($links[$key]) && !$columns[$links[$key]]) {
|
||||||
|
if ($href) { // MySQL EXPLAIN
|
||||||
|
$link = $links[$key] . urlencode($row[array_search("table=", $links)]);
|
||||||
|
} else {
|
||||||
$link = "edit=" . urlencode($links[$key]);
|
$link = "edit=" . urlencode($links[$key]);
|
||||||
foreach ($indexes[$links[$key]] as $col => $j) {
|
foreach ($indexes[$links[$key]] as $col => $j) {
|
||||||
$link .= "&where" . urlencode("[" . bracket_escape($col) . "]") . "=" . urlencode($row[$j]);
|
$link .= "&where" . urlencode("[" . bracket_escape($col) . "]") . "=" . urlencode($row[$j]);
|
||||||
}
|
}
|
||||||
$val = "<a href='" . h(ME . $link) . "'>$val</a>";
|
|
||||||
}
|
}
|
||||||
|
$val = "<a href='" . h(ME . $link) . "'>$val</a>";
|
||||||
}
|
}
|
||||||
echo "<td>$val";
|
echo "<td>$val";
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ Display column collation in tooltip
|
||||||
Keyboard shortcuts: Alt+Shift+1 for homepage, Ctrl+Shift+Enter for Save and continue edit
|
Keyboard shortcuts: Alt+Shift+1 for homepage, Ctrl+Shift+Enter for Save and continue edit
|
||||||
Show only errors with Webserver file SQL command
|
Show only errors with Webserver file SQL command
|
||||||
Remember select export and import options
|
Remember select export and import options
|
||||||
|
Link tables and indexes from SQL command EXPLAIN (MySQL)
|
||||||
Display error with all wrong SQL commands (MySQL)
|
Display error with all wrong SQL commands (MySQL)
|
||||||
Display foreign keys from other schemas (PostgreSQL)
|
Display foreign keys from other schemas (PostgreSQL)
|
||||||
Pagination support (Oracle)
|
Pagination support (Oracle)
|
||||||
|
|
Loading…
Reference in a new issue