I get a strange error when I execute this DQL query:
SELECT u FROM User u LEFT JOIN u.schedule s WHERE DATE(s.timestamp) = DATE(NOW())
The exception is thrown by Doctrine with the message:
Expected known function, got 'DATE'
The problem looks similar to this bug, but that addresses the DATE() function in a GROUP BY clause and the bug is closed for Doctrine 2.2. At this moment, I get the exception with doctrine 2.4-DEV.
The query is meant to select all users scheduled for today. Is there any way I can create this DQL? I tested the SQL version in phpMyAdmin and there the query does not raise an error. What might be wrong?
DateTime
object for "today". And split the datetime field into a "date" and "time" part. I can overcome the first ugly part, but the second is just screwing with your db because an abstraction layer problem. So that's why I hoped for a solution where this would work :) I tried aSELECT CAST(s.timestamp as DATE) as schedule_day FROM ... WHERE schedule_day = :today
but it returned a similar error... – Sciurine