Tuesday, 15 April 2014

php - How to log mysql error via cakephp? -



php - How to log mysql error via cakephp? -

in cakephp controller have next piece of code

if (is_bool($data_model->save($entry))) { cakelog::write('fcshell', "failed saved contact data."); } else { cakelog::write('fcshell', "successfully saved contact info "; }

now want print/check mysql error/warning logs along "failed save" line in fcshell.log file.

only 1 able reproduce problem on 1 of test instance "mysql server has gone away" later not reproduce same error , on production error still exists. need sure if solving right mysql error.

if create debug equal 2 in core.php on production, print errors on web pages.

can help me find way mysql debug logs fcshell logs or other way debug.

based on documentation, save fails when there validation problem.

you can log $data_model->validationerrors instead of trying log sql query. if there model validation error, save query not run.

try like

cakelog::write('fcshell', "failed saved contact data." . var_export($data_model->validationerrors, true));

php mysql debugging cakephp logging

No comments:

Post a Comment