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

Dirk Rauscher dr_typo3 at itb-institut.de
Fri Sep 16 00:09:09 CEST 2011


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