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

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

    Wow, two miserable hours of my life wasted.

    Remember that your beforeSave() must return true!

    0 讨论(0)
  • 2021-01-03 23:52

    may be something like this

    $this->Model->set($this->data);
    
    $errors = $this->Model->validate();// or perhaps validationError(), please confirm
    
    if(!$errors) {
       $this->Model->save();
    }else{
       //show errors
       pr($errors);
    
    }
    
    0 讨论(0)
提交回复
热议问题