$date= $this->Profile->find('all',array(
'conditions'=>array('date(Add date(DOB,interval (year(curdate())-year(DOB)) year))>=date(now())'),
'fields'=>array('date(Add date(DOB,interval (year(curdate())-year(DOB)) year)'),
'limit'=>1,
'order'=>'date(Add date(DOB,interval (year(curdate())-year(DOB)) year))'
));
任何人都可以帮助我....
MySQL查询:
(select date(Adddate(dob,interval (year(curdate())-year(dob)) year))
from profiles
where date(Adddate(dob,interval (year(curdate())-year(dob)) year))>=date(now())
order by date(Adddate(dob,interval (year(curdate())-year(dob)) year)) limit 1 );
答案 0 :(得分:0)
确保您的条件数组声明如下:
'conditions' => array('field >=' => $value) // when condition is >=
'conditions' => array('field <=' => $value) // when condition is <=
'conditions' => array('field' => $value) // when condition is =
如果它不起作用,也许你应该使用custom queries而不是find函数。