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

Franz Koch typo3.RemoveForMessage at elements-net.de
Fri Aug 20 09:33:29 CEST 2010


Hey,

>>>> $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.
>>>
>>> Hey Franz,
>>>
>>> thanks for your suggestion, I didn't think about that, but as I cannot
>>> use domain objects to be mapped on the results, this will work fine!
>>
>> ok, then you can't use the suggestion above, as extbase will try to map the results to a domain
>> object (except if you instantiated a custom QOM).
>
> What will it map? The result set contains only a string value and a count. AFAIK the concept the
> repository should have (as only part of the system) access to DB if required. The framework should
> of course not stand in the way (it should help, not hinder).

by creating a query object like this in your repository:

$query = $this->createQuery();

extbase will automatically bind it to the domain model the repository is 
used for. So by default it will try to map the result set to that model. 
But on writing the lines above I completely forgot the settings 
$query->getQuerySettings()->setReturnRawQueryResult( TRUE );

By doing so, the mapping will not be done of course, but it has to be 
set every time you don't need the mapping.

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list