How to select lines in the last 2 hours in Doctrine
I am trying to fetch the last 2 hours of rows from a Symfony / Doctrine module. In normal MySQL it would be done like this:
SELECT * FROM Posts WHERE
Date> SUBDATE( CURRENT_TIMESTAMP, INTERVAL 2 HOUR)
But Doctrine does not support these MySQL keywords like SUBDATE
and INTERVAL
. The Doctrine documentation provides only alternatives for intervals with days and months. But I need a watch. How to do it?
+3
source to share