Fixed:
-
Getting an aggregate fails when the query has derived fields (defined in the select section) in the order section. Example, reproducing the error:
$database ->table('posts') ->addSelect($database->raw('likes_count + comments_count'), 'acknowledgement') ->orderBy('acknowledgement', 'desc') ->count();
A more live example:
$query = $database ->table('posts') ->addSelect($database->raw('likes_count + comments_count'), 'acknowledgement') ->orderBy('acknowledgement', 'desc'); $paginator = new Pagerfanta(new PagerfantaAdapter($query)); $pagesCount = $paginator->getNbPages();