]> git.joonet.de Git - adminer.git/commitdiff
Respect grouping in computing last page
authorJakub Vrana <jakub@vrana.cz>
Thu, 4 Jul 2013 01:14:32 +0000 (18:14 -0700)
committerJakub Vrana <jakub@vrana.cz>
Thu, 4 Jul 2013 01:14:32 +0000 (18:14 -0700)
adminer/select.inc.php

index 8733f7df21bae60e2df1e4c5ff429a52c1caf52d..df3c3af0afe7b4e6d1fe3e8c74681566ffb2148c 100644 (file)
@@ -237,7 +237,11 @@ if (!$columns) {
        
        $page = $_GET["page"];
        if ($page == "last") {
-               $found_rows = $connection->result("SELECT COUNT(*) FROM " . table($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : ""));
+               $query = " FROM " . table($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : "");
+               $found_rows = $connection->result($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)
+               );
                $page = floor(max(0, $found_rows - 1) / $limit);
        }