[TYPO3-mvc] Using SQL count function in ExtBase query
Michael Knoll
mimi at kaktusteam.de
Thu Aug 19 13:34:15 CEST 2010
> What I did for my project was - I created my own count function in the
> repository like this:
>
> public function count($cat = 0, $kws = array()) {
> $query = $this->createQuery();
>
> $match = null;
>
> if($kws) {
> if($match) {
> $match = $query->logicalAnd($match,
> $query->equals('keywords.uid', $kws));
> } else {
> $match = $query->equals('keywords.uid', $kws);
> }
> }
>
> return $query->matching($match)->count();
> }
>
> in the same way - you could create your own count function and just call
> it with
> $myrepository->count(); and it will return what you need.
>
Hi Daniel,
thanks for your suggestion. But what I get with this solution is only a
count for one query - am I right, I don't get an array of counts for
each aggregated row - what I actually need. So I think, Franz's
suggestion of using a special query will rather fit my needs.
Thanks a lot!
Greez
Mimi
More information about the TYPO3-project-typo3v4mvc
mailing list