1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-20 05:11:25 +02:00

Fix counting rows with grouping outside MySQL

This commit is contained in:
Jakub Vrana
2013-07-03 18:40:55 -07:00
parent 4a6b289c8e
commit 063ddcced5
2 changed files with 32 additions and 18 deletions

View File

@@ -981,6 +981,22 @@ function is_shortable($field) {
return ereg('char|text|lob|geometry|point|linestring|polygon', $field["type"]);
}
/** Get query to compute number of found rows
* @param string
* @param array
* @param bool
* @param array
* @return string
*/
function count_rows($table, $where, $is_group, $group) {
global $jush;
$query = " FROM " . table($table) . ($where ? " WHERE " . implode(" AND ", $where) : "");
return ($is_group && ($jush == "sql" || count($group) == 1)
? "SELECT COUNT(DISTINCT " . implode(", ", $group) . ")$query"
: "SELECT COUNT(*)" . ($is_group ? " FROM (SELECT 1$query$group_by) x" : $query)
);
}
/** Run query which can be killed by AJAX call after timing out
* @param string
* @return array of strings