From e44fbc2e493563ab0e9fcd887457a8948c07f2f5 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Thu, 11 Mar 2010 20:11:31 +0000 Subject: [PATCH] Wrap SQL query git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1343 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- adminer/include/adminer.inc.php | 2 +- adminer/select.inc.php | 6 +++--- editor/include/adminer.inc.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index d853253c..17ed3d31 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -126,7 +126,7 @@ class Adminer { * @return string */ function selectQuery($query) { - return "

" . h($query) . " " . lang('Edit') . "\n"; + return "

" . h(str_replace("\n", " ", $query)) . " " . lang('Edit') . "\n"; } /** Description of a row in a table diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 920b1fc2..f6c1d316 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -23,8 +23,8 @@ list($select, $group) = $adminer->selectColumnsProcess($columns, $indexes); $where = $adminer->selectSearchProcess($fields, $indexes); $order = $adminer->selectOrderProcess($fields, $indexes); $limit = $adminer->selectLimitProcess(); -$from = ($select ? implode(", ", $select) : "*") . " FROM " . idf_escape($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : ""); -$group_by = ($group && count($group) < count($select) ? " GROUP BY " . implode(", ", $group) : "") . ($order ? " ORDER BY " . implode(", ", $order) : ""); +$from = ($select ? implode(", ", $select) : "*") . "\nFROM " . idf_escape($TABLE) . ($where ? "\nWHERE " . implode(" AND ", $where) : ""); +$group_by = ($group && count($group) < count($select) ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : ""); if ($_POST && !$error) { $where_check = "(" . implode(") OR (", array_map('where_check', (array) $_POST["check"])) . ")"; @@ -163,7 +163,7 @@ if (!$columns) { $adminer->selectActionPrint($text_length); echo "\n"; - $query = "SELECT " . (intval($limit) && $group && count($group) < count($select) ? "SQL_CALC_FOUND_ROWS " : "") . $from . $group_by . ($limit != "" ? " LIMIT " . intval($limit) . ($_GET["page"] ? " OFFSET " . ($limit * $_GET["page"]) : "") : ""); + $query = "SELECT " . (intval($limit) && $group && count($group) < count($select) ? "SQL_CALC_FOUND_ROWS " : "") . $from . $group_by . ($limit != "" ? "\nLIMIT " . intval($limit) . ($_GET["page"] ? " OFFSET " . ($limit * $_GET["page"]) : "") : ""); echo $adminer->selectQuery($query); $result = $connection->query($query); diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 568c2fb5..79872930 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -105,7 +105,7 @@ ORDER BY ORDINAL_POSITION"); } function selectQuery($query) { - return "\n"; + return "\n"; } function rowDescription($table) {