Don't modify $query by adminer_select_query
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@801 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
c16c57b1b1
commit
c74c06ad49
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue