bharal
bharal

Reputation: 16174

how do i see cakephp database save errors?

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)

Upvotes: 6

Views: 11093

Answers (1)

marknatividad
marknatividad

Reputation: 630

  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));

Upvotes: 6

Related Questions