[TYPO3-mvc] Using SQL count function in ExtBase query

Franz Koch typo3.RemoveForMessage at elements-net.de
Wed Aug 18 15:07:44 CEST 2010


Hey,

> I would like to do a query like
>
>
> SELECT group.name, count(*) as row_count FROM users
> JOIN group ON users.group_id = group.id
> GROUP BY group.id
>
> (might not be syntactically correct, but I hope you get the idea).
>
> Is there any possibility to do that with extbase query object?

It should be, but not for repositories if you intend to do that. If you 
like to use this query in a repository to get mapped objects back you 
need to call this query via a custom statement which is also possible.

$query = $this->createQuery();
return $query->statement('SELECT ...')->execute();


If you just like to use the QOM to build such a query (so outside of a 
repository) it should be possible, but I can't tell you how as I'm not 
too familiar with internals of the QOM layer yet.
-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list