如何使 Doctrine_Expression ( Doctrine 1.2 ) 尝试获取最后 7 天
我尝试用原则 1.2 进行此查询:
$q->where('date > ?',
new Doctrine_Expression('DATE_SUB(CURDATE() , INTERVAL 7 DAY)'));
但它没有返回任何结果。
有什么想法吗?
谢谢
I try to make this query with doctrine 1.2:
$q->where('date > ?',
new Doctrine_Expression('DATE_SUB(CURDATE() , INTERVAL 7 DAY)'));
but it's not return me any results.
any idea ?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
它不返回任何内容的原因是因为 Doctrine 转义了表达式 - 生成的 SQL 是
而不是
您可以强制它像这样工作:
然而,这不是最安全的选项,因为输入不会转义并且是不是好习惯...
The reason why it doesn't return anything is because Doctrine escapes the expression - the generated SQL is
rather than
You could force it to work like this:
This isn't the safest option however, as the input doesn't get escaped and isn't good practice...