how to make Doctrine_Expression ( doctrine 1.2 ) try to get last 7 days

孤街醉人 提交于 2019-12-02 04:43:19

The reason why it doesn't return anything is because Doctrine escapes the expression - the generated SQL is

WHERE (date > 'DATE_SUB(CURDATE(), INTERVAL 7 DAY)')

rather than

WHERE (l.action_time > DATE_SUB(CURDATE(), INTERVAL 7 DAY))

You could force it to work like this:

$date = new Doctrine_Expression('DATE_SUB(CURDATE() , INTERVAL 7 DAY)');
$q->where('date > ' . $date);

This isn't the safest option however, as the input doesn't get escaped and isn't good practice...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!