diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 633fab65..9937689d 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -57,6 +57,14 @@ function adminer_select_query($query) { return call_adminer('select_query', "
" . htmlspecialchars($query) . "
" . lang('Edit') . "\n", $query);
}
+/** Value printed in select table
+* @param string escaped value to print
+* @return string link to foreign key
+*/
+function adminer_select_val($val, $link) {
+ return call_adminer('select_val', ($link ? '' . $val . '' : $val), $val, $link);
+}
+
/** Query printed after execution in the message
* @param string executed query
* @return string
diff --git a/adminer/select.inc.php b/adminer/select.inc.php
index c256c3c0..b519a548 100644
--- a/adminer/select.inc.php
+++ b/adminer/select.inc.php
@@ -265,6 +265,12 @@ if (!$columns) {
if (!$result->num_rows) {
echo "
'; - foreach ($row as $key => $val) { - echo ' | ' . adminer_field_name($fields, $key) . ''; - } - echo " |
---|---|
"; + foreach ($rows[0] as $key => $val) { + echo ' | ' . adminer_field_name($fields, $key) . ''; + } + echo " |
' . (count($select) != count($group) || information_schema($_GET["db"]) ? '' : ' ' . lang('edit') . '');
foreach ($row as $key => $val) {
@@ -302,29 +306,32 @@ if (!$columns) {
$val = "$val ";
}
}
+
+ // link related items
+ $link = "";
foreach ((array) $foreign_keys[$key] as $foreign_key) {
if (count($foreign_keys[$key]) == 1 || count($foreign_key["source"]) == 1) {
- // link related items
- $val = "\">$val";
foreach ($foreign_key["source"] as $i => $source) {
- $val = "&where%5B$i%5D%5Bcol%5D=" . urlencode($foreign_key["target"][$i]) . "&where%5B$i%5D%5Bop%5D=%3D&where%5B$i%5D%5Bval%5D=" . urlencode($row[$source]) . $val;
+ $link .= "&where%5B$i%5D%5Bcol%5D=" . urlencode($foreign_key["target"][$i]) . "&where%5B$i%5D%5Bop%5D=%3D&where%5B$i%5D%5Bval%5D=" . urlencode($row[$source]);
}
- $val = '$val";
}
+ echo "\n";
}
echo " |
"; - // use num_rows without LIMIT, COUNT(*) without grouping, FOUND_ROWS otherwise (slowest) + // use count($rows) without LIMIT, COUNT(*) without grouping, FOUND_ROWS otherwise (slowest) $found_rows = (intval($limit) ? $dbh->result($dbh->query(count($group) < count($select) ? " SELECT FOUND_ROWS()" // space to allow mysql.trace_mode : "SELECT COUNT(*) FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : "") - )) : $result->num_rows); + )) : count($rows)); if (intval($limit) && $found_rows > $limit) { // display first, previous 3, next 3 and last page $max_page = floor(($found_rows - 1) / $limit); @@ -346,7 +353,6 @@ if (!$columns) { echo (information_schema($_GET["db"]) ? "" : "
\n"); echo "\n"; } - $result->free(); echo "\n"; //! Editor only diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index b4dea4d8..20def63a 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -28,6 +28,10 @@ function adminer_select_query($query) { return call_adminer('select_query', "\n", $query); } +function adminer_select_val($val, $link) { + return call_adminer('select_val', ($link ? '' . $val . '' : $val), $val, $link); +} + function adminer_message_query($query) { return call_adminer('message_query', "", $query); }