[TYPO3-mvc] Count query results
Stefan Isak
stefanisak at googlemail.com
Tue May 18 18:21:05 CEST 2010
Hi Jochen,
the very first thing I thought was that it just isn't what I expected.
But I realized that the same query is correct when I simply execute it.
Maybe the problem is that I use constraints with m:m relations like
$query->equals('objects.uid');
I think those relations can't be resolved by the count() method unlike the
execute() method.
Am I wrong or if not, is there a workaround?
So long.
Stefan
2010/5/18 Jochen Rau <jochen.rau at typoplanet.de>
> 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
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>
More information about the TYPO3-project-typo3v4mvc
mailing list