Closed
Description
(Sorry, i am chinese! Too bad English.)
When QueryBuider presence group by, count is not accurate.
My Code
class MyQueryBuilder extends \Phalcon\Paginator\Adapter\QueryBuilder
{
public function getPaginate()
{
$paginate = parent::getPaginate();
$builder = $this->getQueryBuilder();
if ($group = $builder->getGroupBy()) {
$result = $builder->columns('count(distinct ' . $group . ') as total')
->groupBy(null)
->getQuery()
->execute()
->getFirst();
$paginate->total_items = $result->total;
$paginate->total_pages = ceil($paginate->total_items / $this->getLimit());
}
return $paginate;
}
}
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Metadata
Assignees
Labels
No labels