0

我无法让查询返回预期结果。从 cakephp 1.1 迁移到 1.3。目前,我的新查询没有返回任何结果。得到结果后,我需要限制为 5。 now() 在我的$sqlConditions数组中是否正确?有什么建议么?感谢您的关注。

旧查询 cakephp 1.1:

function listcomingevents() {
    $conditions="EventsDate.start_date>=now()";
    $this->weekevent="EventsDate.start_date ASC";
    $listcomingeventdata=$this->EventsDate->findAll($conditions,'',$this->weekevent,'5');
    return $listcomingeventdata;
}

新查询 cakephp 1.3:

function listcomingevents() {
    $sqlConditions = array( "EventsDate.start_date >="=>"now()");

    //remaining code
    $sqlOrderBy = array("EventsDate.start_date asc");
    $sqlParams = array('conditions'=>$sqlConditions,'order'=>$sqlOrderBy);
    $listcomingeventdata=$this->EventsDate->find('all',$sqlParams);
    return $listcomingeventdata;
}

也试过:

$sqlConditions = array("EventsDate.start_date >="=>"CURDATE()");   
4

1 回答 1

1

只需将NOW()表达式直接放在左侧即可,例如

   $sqlConditions = array( "EventsDate.start_date >= CURDATE()"); 
于 2013-03-21T17:39:24.630 回答