Zend Framework paginator与GROUP BY无法正常工作..?

I have following code :

$select = new Select('tier');
$select->group('tierGroup');


$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Tiers());

$paginatorAdapter = new DbSelect($select, $this->tableGateway->getAdapter(), $resultSetPrototype);
$paginator = new Paginator($paginatorAdapter);

It works perfectly fine if i remove the group by clause but with group by it counts all the rows of table and show more pages than data.

Any help will be appreciated.

There are multiple issues talking about this problem, it seems that the adapter can't figure the number of rows returned somehow. You should use setRowCount() methods in your controller.

paginatorAdapter = new DbSelect($select, $this->tableGateway->getAdapter(), $resultSetPrototype);
$paginatorAdapter->setRowCount((int)trim($select->getCount()));.
$paginator = new Paginator($paginatorAdapter);

Hope this little hack will work for you