Skip to content

Commit

Permalink
Merge pull request #25 from AppsDevTeam/overwritable-count-expr
Browse files Browse the repository at this point in the history
Overwritable count expr
  • Loading branch information
thorewi authored Nov 2, 2022
2 parents b748af6 + e686c59 commit faa403b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/QueryObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ final public function count(): int
{
$qb = $this->createQueryBuilder(false);

$qb->select('COUNT(e.id)');
$qb->select('COUNT(' . $this->getCountExpr() . ')');

if ($qb->getDQLPart('groupBy')) {
$paginator = new Doctrine\ORM\Tools\Pagination\Paginator($qb);
Expand All @@ -539,6 +539,11 @@ final public function count(): int

return (int) $query->getSingleScalarResult();
}

protected function getCountExpr(): string
{
return $this->entityAlias . '.id';
}

final public function getResultSet(int $page, int $itemsPerPage): ResultSet
{
Expand Down

0 comments on commit faa403b

Please sign in to comment.