It does not take into account if there is a HAVING clause filtering out rows.
Are there any obstacles to using the builtin doctrine solution? (which counts correctly)
use Doctrine\ORM\Tools\Pagination\Paginator;
protected function getCount(QueryBuilder $queryBuilder, mixed $identifier): int
{
$paginator = new Paginator($queryBuilder->getQuery(), true);
return $paginator->count();
}
It does not take into account if there is a HAVING clause filtering out rows. Are there any obstacles to using the builtin doctrine solution? (which counts correctly)