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

后端 未结 8 1957
一个人的身影
一个人的身影 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:29

    To debug Model->save() check the validation errors and the last sql query

    $this->Model->save($data);
    
    debug($this->Model->validationErrors); //show validationErrors
    
    debug($this->Model->getDataSource()->getLog(false, false)); //show last sql query
    

提交回复
热议问题