在我的cakephp控制器中,我有以下代码
if (is_bool($data_model->save($entry)))
{
CakeLog::write('fcshell', "Failed to saved contact data.");
}
else
{
CakeLog::write('fcshell', "Successfully saved contact data ";
}
现在我要打印/检查mysql错误/警告日志以及"无法保存" fcshell.log文件中的行。
只有一个我能够在其中一个测试实例上重现问题,这个测试实例已经消失了#34; mysql服务器已经消失了#34;但后来无法重现相同的错误,在生产中仍然存在一些错误。我需要确定我是否正在解决正确的mysql错误。
如果我在生产中的core.php中将调试等于2,则会在网页上打印错误。
有人可以帮我找到一种方法来获取使用fcshell日志的mysql调试日志或任何其他调试方式。
答案 0 :(得分:0)
根据documentation,save
通常会在出现验证问题时失败。
您可以记录$data_model->validationErrors
,而不是尝试记录SQL查询。如果存在模型验证错误,则save
查询将不会运行。
尝试类似
的内容CakeLog::write('fcshell', "Failed to saved contact data." . var_export($data_model->validationErrors, true));