Fixed regression in db_pager.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 6 May 2015 20:30:47 +0000 (22:30 +0200)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 6 May 2015 20:31:07 +0000 (22:31 +0200)
includes/db_pager.inc

index c2ae04b6ecbd15b474981232b1fee77c8dfdfc39..522b04b6873eb1aa9da1ca2258fa8c053c6d8574 100644 (file)
@@ -287,11 +287,8 @@ class db_pager {
                }
                if ($where) $where = " WHERE ($where)";
 
-               if ($count) {
-                       $group = $group == '' ? "*" : "DISTINCT $group";
-
-                       return "SELECT COUNT(*) FROM (SELECT $group FROM $from $where) tmp_count";
-               }
+               if ($count)
+                       return "SELECT COUNT(*) FROM ($this->sql) tmp_count";
 
                $sql = "$select FROM $from $where";
                if ($group) $sql.= " GROUP BY $group";
@@ -303,8 +300,8 @@ class db_pager {
                                        if(isset($col['ord_priority'])) {
                                                $columns[$col['ord_priority']] = $col;
                                        }
-                       }
-                       krsort($columns);
+               }
+               krsort($columns);
 
            foreach ($columns as $col) {
                if (isset($col['ord'])) {
@@ -313,7 +310,7 @@ class db_pager {
                            }
                        }
            }
-                               
+
            if (count($ord)) {
                        $ord = array_map(function_exists('mysql_real_escape_string') ? 
                                'mysql_real_escape_string': 'mysql_escape_string', $ord);