cakeWarning(2):非法偏移类型[CORECakeModelModel.php,第2978]行


cakeWarning (2): Illegal offset type [CORECakeModelModel.php, line 2978]

我有个问题,请帮我

谢谢。。

我的cakephp是2.5.4,我使用xampver3.2.1,但我得到了这个错误。

Warning (2): Illegal offset type [CORE'Cake'Model'Model.php, line 2978]

警告(2):非法偏移类型[CORE''Cake''Model''Model.php,第2956行]

我的面纱是:

public function edit($id=null) {
    if(!$id) {      
        $this->Session->setFlash('not found this job');
        $this->redirect(array('action'=>'index'),null,true);
    }
    if(empty($this->data)) {
        $this->data=$this->Task->find(array('all',array('conditions'=>array('id'=>$id))));
    } else {            
        if($this->Task->save($this->data)) {
            $this->Session->setFlash('updated');
            $this->redirect(array('action'=>'index'),null,true);
        } else {
            $this->Session->setFlash('this up date has problem !!! ');
        }
    }
}

我的控制器是:

public function edit($id=null) {
    if(!$id) {      
        $this->Session->setFlash('not found this job');
        $this->redirect(array('action'=>'index'),null,true);
    }
    if(empty($this->data)) {
        $this->data=$this->Task->find(array('all',array('conditions'=>array('id'=>$id))));
    } else  {
        if($this->Task->save($this->data)) {
            $this->Session->setFlash('updated');
            $this->redirect(array('action'=>'index'),null,true);
        } else {
            $this->Session->setFlash('this up date has problem !!! ');
        }
    }

}

请帮我

您使用了Model::find()错误,应该作为单独参数传递的内容被封装在数组中。

必须是

find('all', array('conditions' => /* ... */));

不是

find(array('all', array('conditions' => /* ... */)));