How to debug when CakePHP Model::save() doesn't attempt an INSERT

后端 未结 8 1953
一个人的身影
一个人的身影 2021-01-03 23:22

I am having a bear of a time saving the simplest record from a model called ItemView:

if($this->save($this->data)) {
  echo \'worked\';
} else {
  echo         


        
8条回答
  •  北海茫月
    2021-01-03 23:30

    What is the name of controller you are using?

    Mismatching the name of controller and model also cause some errors. If you are using Posts controller then the Post model should be used. If you are using Post model inside other controller; say BlogsController then the Post model should be loaded like following:

        loadModel("Post");    
                //Here I'm loading other model inside blogs controller
                if($this->request->is('post'))
                {
                    $this->Post->save($this->request->data);
                }
            }
        }
        ?>
    

提交回复
热议问题