diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php
index fe94acf4..bbc77a77 100644
--- a/adminer/include/adminer.inc.php
+++ b/adminer/include/adminer.inc.php
@@ -47,19 +47,14 @@ function adminer_select_links($table_status) {
return call_adminer('select_links', '' . lang('Table structure') . '', $table_status);
}
-/** Process and print select query before execution
+/** Query printed in select before execution
* @param string query to be executed
* @return string
*/
function adminer_select_query($query) {
global $SELF;
// it would be nice if $query can be passed by reference and printed value would be returned but call_user() doesn't allow reference parameters
- $return = call_adminer('select_query', "", $query);
- if (!$return) {
- echo "
" . htmlspecialchars($query) . "
" . lang('Edit') . "
\n";
- return $query;
- }
- return $return;
+ return call_adminer('select_query', "" . htmlspecialchars($query) . "
" . lang('Edit') . "
\n", $query);
}
/** Query printed after execution in the message
diff --git a/adminer/select.inc.php b/adminer/select.inc.php
index afb2ffd1..471f2872 100644
--- a/adminer/select.inc.php
+++ b/adminer/select.inc.php
@@ -239,7 +239,7 @@ if (!$columns) {
echo "\n";
$query = "SELECT " . (count($group) < count($select) ? "SQL_CALC_FOUND_ROWS " : "") . $from . $group_by . (strlen($limit) ? " LIMIT " . intval($limit) . (intval($_GET["page"]) ? " OFFSET " . ($limit * $_GET["page"]) : "") : "");
- $query = adminer_select_query($query);
+ echo adminer_select_query($query);
$result = $dbh->query($query);
if (!$result) {
diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php
index b8ebf18f..7be722b6 100644
--- a/editor/include/adminer.inc.php
+++ b/editor/include/adminer.inc.php
@@ -25,29 +25,11 @@ function adminer_select_links($table_status) {
}
function adminer_select_query($query) {
- $join = "";
- $i = 1;
- foreach (foreign_keys($_GET["select"]) as $foreign_key) {
- $on = array();
- foreach ($foreign_key["source"] as $key => $val) {
- $on[] = "`t0`." . idf_escape($val) . " = `t$i`." . idf_escape($foreign_key["target"][$key]);
- }
- //~ $join .= "\nLEFT JOIN " . idf_escape($foreign_key["table"]) . " AS `t$i` ON " . implode(" AND ", $on);
- //! use in select
- $i++;
- }
- $query = preg_replace("~((?:[^'`]*|'(?:[^'\\\\]*|\\\\.)+')+)(`((?:[^`]+|``)*)`)~", '\\1`t0`.\\2', $query); // don't match ` inside ''
- $query = preg_replace('~ FROM `t0`.(`((?:[^`]+|``)*)`) ?~', "\nFROM \\1 AS `t0`" . addcslashes($join, '\\$') . "\n", $query);
- $return = call_adminer('select_query', "", $query);
- if (!$return) {
- echo "\n";
- return $query;
- }
- return $return;
+ return call_adminer('select_query', "\n", $query);
}
function adminer_message_query($query) {
- return call_adminer('message_query', "", $query);
+ return call_adminer('message_query', "", $query);
}
function adminer_navigation($missing) {