Count all rows in compound query

I have compound query

$query = $this->getDi()->get('modelsManager')->createBuilder()
->columns(...)
->from(...)
->join(...)
->join(...)
...
->where(...)
->orderBy(...)
->limit(12)
...

How count all rows without limit?

I think it should be works.

$query = $this->getDi()->get('modelsManager')->createBuilder()
->columns(...)
->from(...)
->join(...)
->join(...)
...
->where(...)
->orderBy(...)
//->limit(12) // remove
->count(); // add

Hi @stanleer you can get the count with this simple way


    $myCount = $this->getDi()->get('modelsManager')->createBuilder()
    ->columns(['myCount' => 'count(*)']) //myCount alias
    ->from(...)
    ->where(...)
    ->getQuery()
    ->setUniqueRow(true)
    ->execute()
    ->myCount; //myCount property

Good luck