1

I am trying to save an item through my model, but saving fails.

When I output validationErrors - I get empty array, so no validation problems seem to be available. What could be failing my save()?

function resave($wid, $kTime){
    $this->contain();
    $word = $this->getById($wid);
    // Successfully tretrieved here
    $word['ModelName']['column'] = $kTime;
    if($this->save($word)){
        return 'success';
    }else{
        // this returns empty array
        return $this->validationErrors;
    }
}

2 Answers 2

2

To save yourself some time in the future, if a save() isn't working, the first place to look is in your SQL log and errors.

You should try installing Debug Kit Toolbar for CakePHP (https://github.com/cakephp/debug_kit). It makes it easy to view your SQL log, along with a bunch of other useful stuff. Or, alternatively, you can just put this in your layout file to view SQL history/errors:

<?php echo $this->element('sql_dump'); ?>
Sign up to request clarification or add additional context in comments.

Comments

1

It was a problem with float and array type. I investigated it with gettype() and figured it out.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.