【发布时间】:2013-07-13 01:59:52
【问题描述】:
在我的控制器中,我有这个添加功能:
public function add(){
$this->layout = false;
if($this->request->is('post')){
$this->Paciente->create();
$this->Paciente->set($this->request->data);
if ($this->Paciente->validates()) {
if($this->Paciente->save()){
$this->set('status', '200');
} else {
// debug($this->Paciente->validationErrors);
// ini_set('memory_limit', '-1');
// var_dump($this->Paciente);
$this->set('status', '101');
// $log = $this->Paciente->getDataSource()->getLog(false, false);
// debug($log);
// die;
}
} else {
// didn't validate logic
// $errors = $this->Paciente->validationErrors;
// debug($errors);
$this->set('status', '100');
}
} else
$this->set('status', '404');
}
我正在发送帖子信息,状态始终为 101。如您所见,我已经尝试了很多来找出错误所在,但没有运气。
我的模型中也没有任何回调(beforeSave、afterSave...)...
有人知道发生了什么吗?
【问题讨论】:
-
您禁用了布局。你需要吗?只需尝试删除该行并尝试。
-
您的调试级别是 2 吗?日志是怎么说的?
-
我建议您简单地调试 save 方法并确定它返回 false 的位置 - 基于它应该更清楚您的模型如何验证但不保存。