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

警告(2):偏移类型非法[CORE\Cake\Model\Model.php,第2978行],php,cakephp,Php,Cakephp,我有个问题,请帮帮我 谢谢 我的cake php是2.5.4,我使用的是xampp版本3.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) { $t

我有个问题,请帮帮我

谢谢

我的cake php是2.5.4,我使用的是xampp版本3.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 !!! ');
        }

    }


}
请帮助我

您使用的是错误的,应该作为单独参数传递的内容被包装在一个数组中

一定是这样

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


你的模型有问题。请把它寄出去。您可能可以删除控制器的view and controllerPlease post here标题,因为我们甚至无法猜测您是否初始化了模型。在我的例子中,我是在执行
find($id)
,而不是
findById($id)
find(array('all', array('conditions' => /* ... */)));