diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 2cd5831e..263d6c02 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -452,6 +452,19 @@ username.form['auth[driver]'].onchange(); return false; } + /** Build SQL query used in select + * @param array result of selectColumnsProcess()[0] + * @param array result of selectSearchProcess() + * @param array result of selectColumnsProcess()[1] + * @param array result of selectOrderProcess() + * @param int result of selectLimitProcess() + * @param int index of page starting at zero + * @return string empty string to use default query + */ + function selectQueryBuild($select, $where, $group, $order, $limit, $page) { + return ""; + } + /** 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 fefc6204..ec1af082 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -230,7 +230,16 @@ if (!$columns) { $page = floor(max(0, $found_rows - 1) / $limit); } - $query = "SELECT" . limit((+$limit && $group && count($group) < count($select) && $jush == "sql" ? "SQL_CALC_FOUND_ROWS " : "") . $from, ($where ? "\nWHERE " . implode(" AND ", $where) : "") . $group_by, ($limit != "" ? +$limit : null), ($page ? $limit * $page : 0), "\n"); + $query = $adminer->selectQueryBuild($select, $where, $group, $order, $limit, $page); + if (!$query) { + $query = "SELECT" . limit( + (+$limit && $group && count($group) < count($select) && $jush == "sql" ? "SQL_CALC_FOUND_ROWS " : "") . $from, + ($where ? "\nWHERE " . implode(" AND ", $where) : "") . $group_by, + ($limit != "" ? +$limit : null), + ($page ? $limit * $page : 0), + "\n" + ); + } echo $adminer->selectQuery($query); $result = $connection->query($query); diff --git a/changes.txt b/changes.txt index 6fb51734..405b0da9 100644 --- a/changes.txt +++ b/changes.txt @@ -4,6 +4,7 @@ Edit strings with \n in textarea Time out long running database list and select count Use VALUES() in INSERT+UPDATE export Style logout button as link +selectQueryBuild() method (customization) Adminer 3.5.1 (released 2012-08-10): Support same name fields in CSV export diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index ea66d33f..d8e1fa41 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -411,6 +411,10 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 return false; } + function selectQueryBuild($select, $where, $group, $order, $limit, $page) { + return ""; + } + function messageQuery($query) { return " " . @date("H:i:s") . ""; }