[TYPO3-mvc] How to add a SQL function in a query

Rayuth You rayuth at web-essentials.asia
Fri Sep 16 03:21:05 CEST 2011


Hi Dirk

Due to your SQL query, you can change into:

$query->matching(
$query->logicalAnd(
$query->equals('crdate',strtotime('2011')),
$query->equals('name','blabla')
)->execute();

The hidden field you no need to put because extbase will do it for you.
It may works, I hope :)

Cheers,
Yuth

On 09/16/2011 05:09 AM, Dirk Rauscher wrote:
> Hi members,
>
> I want to construct a sql-query in my repository that looks like that in
> SQL language:
>
> SELECT * FROM TABLENAME WHERE YEAR(crdate) = '2011' AND hidden=0 AND
> name='blabla'
>
>
> First I tried it this way:
>
>
> $query->matching(
> $query->logicalAnd(
> $query->equals('YEAR(crdate)','2011')),
> $query->equals('hidden',0)),
> $query->equals('name','blabla')
> )->execute();
>
>
> but I found that 'YEAR(crdate)' is interpreted as a field named
> 'y_e_a_r...' and therfore the query generates an exception.
>
> I don't want to use $query->statement(...) as I will lose the
> abstraction from a concrete storage backend (database).
>
>
> How can i build such a query by using the Tx_Extbase_Persistence_Query ?
> Any hint will be highly appreciated... :-)
>
> Cheers Dirk
>
>



More information about the TYPO3-project-typo3v4mvc mailing list