]> git.joonet.de Git - adminer.git/commitdiff
Don't modify $query by adminer_select_query
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Sat, 11 Jul 2009 19:52:48 +0000 (19:52 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Sat, 11 Jul 2009 19:52:48 +0000 (19:52 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@801 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/include/adminer.inc.php
adminer/select.inc.php
editor/include/adminer.inc.php

index fe94acf4a6404e6be459d68d6f086c9b3ff205a3..bbc77a77ef92221811dddfc17c8acbd7c76d5368 100644 (file)
@@ -47,19 +47,14 @@ function adminer_select_links($table_status) {
        return call_adminer('select_links', '<a href="' . htmlspecialchars($SELF) . (isset($table_status["Engine"]) ? 'table=' : 'view=') . urlencode($_GET['select']) . '">' . lang('Table structure') . '</a>', $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 "<p><code class='jush-sql'>" . htmlspecialchars($query) . "</code> <a href='" . htmlspecialchars($SELF) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a></p>\n";
-               return $query;
-       }
-       return $return;
+       return call_adminer('select_query', "<p><code class='jush-sql'>" . htmlspecialchars($query) . "</code> <a href='" . htmlspecialchars($SELF) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a></p>\n", $query);
 }
 
 /** Query printed after execution in the message
index afb2ffd1feb99aae6e1713e4914d580457d20bf1..471f28726b94bbeac37004cde64245ff18431cde 100644 (file)
@@ -239,7 +239,7 @@ if (!$columns) {
        echo "</form>\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) {
index b8ebf18f30e688401c5f39fc01708e5c7b37d89d..7be722b64719367e1b1d2fe7e6edef3588621106 100644 (file)
@@ -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 "<!-- " . str_replace("--", " --><!-- ", $query) . " -->\n";
-               return $query;
-       }
-       return $return;
+       return call_adminer('select_query', "<!-- " . str_replace("--", "--><!--", $query) . " -->\n", $query);
 }
 
 function adminer_message_query($query) {
-       return call_adminer('message_query', "<!-- " . str_replace("--", " --><!-- ", $query) . " -->", $query);
+       return call_adminer('message_query', "<!-- " . str_replace("--", "--><!--", $query) . " -->", $query);
 }
 
 function adminer_navigation($missing) {