cakephp:如何使NOW()工作在搜索条件? [英] cakephp: how to make NOW() work in search condition?

查看:74
本文介绍了cakephp:如何使NOW()工作在搜索条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要获得所有日期大于现在的记录。我尝试了这个,但它doeasnt工作:

  $ all_dates = $ this-> TourDate-& array('conditions'=> array('TourDate.date> ='=>'NOW()'),'order'=> array('TourDate.date ASC'))); 

如果我用当前日期替换NOW为什么?

解决方案

我不使用 CakePHP 确保你的'NOW()'正在解析为字符串,最后你得到像

  TourDate.date> ='NOW()'

也许你应该试试

  array('TourDate.date> = NOW()')
/ pre>

作为值,而不是将其分割为 key => value style?


I'm trying to get all records with date greater then now. I tried this but it doeasnt work:

$all_dates = $this->TourDate->find('all', array('conditions' => array('TourDate.date >=' => 'NOW()'), 'order' => array('TourDate.date ASC')));

If I replace NOW() with the current date it works. Why's that?

解决方案

I do not use CakePHP but I am pretty sure that your 'NOW()' is parsing to string and finally you got something like

TourDate.date >= 'NOW()'

Maybe you should just try

array('TourDate.date >= NOW()')

as a value only instead of spliting it to key => value style ?

这篇关于cakephp:如何使NOW()工作在搜索条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆