Open
Description
In mysql COUNT (DISTINCT col1, col2, col3)
will not count any results that have one of the columns NULL.
However SELECT (DISTINCT col1, col2, col3)
will show those rows with NULL as part of the result.
This is a problem when using the phalcon paginator with GROUP BY queries. The results that have NULL on one of the columns in the GROUP BY will not be counted.
I suggest adding an option to provide the columns for the total count on group by queries, similar to the having queries.
For example, create paginator like this:
$paginator = new PaginatorQueryBuilder([
'builder' => $query,
'limit' => 1,
'page' => 1,
'columns' => 'IFNULL(col1,0) , IFNULL(col2,0) , col3',
]);
And then use the columns parameter in the total query here, instead of the groupColumn variable:
cphalcon/phalcon/Paginator/Adapter/QueryBuilder.zep
Lines 192 to 196 in fe17e3a
Metadata
Metadata
Assignees
Type
Projects
Status
In Progress