6

if i have a cake php saveAll method like so:

if ($this->Video->saveAll($this->data)){
    ... // stuff that never happens, sadly
} else {
    ...
    $this->Session->setFlash('boo! hss! error here');
}

how do i print out the database error? I tried:

    $this->Session->setFlash('boo! hss! error here' . print_r($this->Video->validationErrors,true);

but that didn't work (it just showed me an empty array)

cheerio!

UPDATE: ah. So, the problem is that, while normally i'd get the database error, i was using the old prg mechanism, and cake doesn't (magically) show the db errors on redirect pages.

Fair enough, but in the future, how the heck am i meant to see the db errors on a redirect page (that is, the question still stands, its just that most people probably just SEE the error, and don't need to do anything to get it)

1
  • Maybe the debug() function does what you need? Commented Jan 24, 2012 at 9:18

1 Answer 1

6
  1. make sure debug is set to 2 in config/core.php

  2. print error messages to the log file like so:

    $this->log(print_r($this->Video->validationErrors, true));

Sign up to request clarification or add additional context in comments.

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.