2013-12-20 4 views
-4
$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))' 
     )); 

이 사람이 나를 도울 수 ....CakePHP의 쿼리에서 날짜를 얻는 방법

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

확인하여 조건 배열을 확인은 다음과 같이 선언한다 :

'conditions' => array('field >=' => $value) // when condition is >= 
'conditions' => array('field <=' => $value) // when condition is <= 
'conditions' => array('field' => $value) // when condition is = 

그리고 작동하지 않는 경우 찾기 기능 대신 custom queries을 사용해야 할 수도 있습니다.

관련 문제