当模型没有保存或返回任何类型的错误时该怎么办?
$data = array(
'Model' => array(
'field1' => 'value1',
'field2' => 'value2',
)
);
try {
// Forget to add this
$this->Model->set($data);
if (!$this->Model->validates()) { // Returns true
throw new GenericErrorException("Can't validate");
}
$this->Model->create();
if (!$this->Model->save($data)) { // Returns false
debug($this->Model->invalidFields()); // Empty array
debug($this->Model->getDatasource()->getLog()); // Returns array without INSERT/UPDATE
throw new GenericErrorException("Can't save");
}
} catch(Exception $e) {
// LOG ERROR
}
我能做些什么来验证发生了什么错误吗?