[TYPO3-mvc] Count query results

Jochen Rau jochen.rau at typoplanet.de
Tue May 18 17:23:40 CEST 2010


Hi Stefan.

On 18.05.10 11:04, Stefan Isak wrote:
> Hey,
>
> got a question on counting rows of a query.
> What is the best approach to get the number of results for a query having
> constraints?
>
> This is my query:
>    $query = $this->createQuery();
>    $constraints = array();
>    $constraints[] = $query->equals(...);
>    $constraints[] = $query->equals(...);
>    $query->matching($query->logicalAnd($constraints))->execute();
>
> What I tried was
>    $query->matching($query->logicalAnd($constraints))->count();
>
> Although the result is a number, it is a wrong one.
>
> Any suggestions on that?

This is the best approach. Maybe the number is right but does not fit to 
you expectations ;-)

Could you please post the result you expected and the actual result? 
What do you want to count?

Regards
Jochen


More information about the TYPO3-project-typo3v4mvc mailing list