an order by,
<?php
$builder = $this->getModelsManager()->createBuilder()
->from('table')
->orderBy('id DESC')
;
$pager = new \Phalcon\Paginator\Adapter\QueryBuilder(array(
'builder' => $builder,
'limit' => 10,
'page' => 1,
));
$pager->getPaginate();
will result in something like this
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42803]: Grouping error: 7 ERROR: column "id" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: ...(*) AS "rowcount" FROM "table" ORDER BY "id... ^' in
an ORDER BY fields should be omitted, when generating count(*) query.. otherwise postgres requires those fields to be grouped