doctrine - how to use cast() in DQL?
Hi!
I just hit a brick wall when using a cast function in dql: Code:
PHP Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message '[Syntax Error] line 0, col 125: Error: Expected known function, got 'date'' in /home/antoranz/Descargas/php/DoctrineORM-2.2.1/Doctrine/ORM/Query/QueryException.php:42 Just in case, what I need is get entities of which a datetime field matches today (in other words, match only the date). I'm using something like this: Code:
$em->createQuery("select u from Entity u where cast(u.datetimefield as date)=CURRENT_DATE"); |
Do you need the CAST() bit? In SQL, I would just make sure CURRENT_DATE is a string in the same format as the datetimefield, and then used a normal "WHERE x=y" clause. Is it different for DQL?
|
All times are GMT -5. The time now is 07:46 AM. |