]> git.joonet.de Git - adminer.git/commitdiff
Fix count_rows with more than one group by column
authorJakub Vrana <jakub@vrana.cz>
Thu, 1 Feb 2018 19:45:49 +0000 (20:45 +0100)
committerJakub Vrana <jakub@vrana.cz>
Thu, 1 Feb 2018 19:45:49 +0000 (20:45 +0100)
adminer/include/functions.inc.php

index 9f78c205a5e327138680d226d8f87f693bcba2f3..a92e7042902225225e000324ff9b5bbbc3a385c3 100644 (file)
@@ -1292,7 +1292,7 @@ function count_rows($table, $where, $is_group, $group) {
        $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)
+               : "SELECT COUNT(*)" . ($is_group ? " FROM (SELECT 1$query GROUP BY " . implode(", ", $group) . ") x" : $query)
        );
 }