save()返回false,但在CakePHP中没有错误 [英] save() returning false, but with no error in CakePHP
问题描述
我的调试值设置为 2
,它显示所有查询,除了我需要的。
My debug value is set to 2
, and it's displaying all the queries, except the one I need.
我有一个 Items
控制器方法在 User
模型中调用此方法( ):
I have an Items
controller method that is calling this method in the User
model (Item belongsTo User):
function add_basic($email, $password) {
$this->create();
$this->set(array(
'email' => $email,
'password' => $password
));
if($this->save()) {
return $this->id;
}
else {
return false;
}
}
我已确认 $电子邮件
和 $ password
正确传递到函数中(并使用合法数据填充)。 电子邮件
和密码
是 User
model。
I have confirmed that $email
and $password
are being passed into the function correctly (and are populated with legit data). email
and password
are the names of the fields in the User
model.
我也确认在 $ this-> save()
c $ c> false ,但是当我查看发生这种情况的页面时,查询没有在调试中打印,并且没有错误被抛出,所以我不知道什么错误。
I have also confirmed that on $this->save()
it is returning false
, but when I view the page where this occurs, the query is not being printed in the debug, and there is no error being thrown, so I have no idea whats going wrong.
有关如何查看错误的任何想法,或为什么查询似乎未被执行?
Any ideas on how I can see the error, or why the query doesn't seem to be getting executed?
这很奇怪,因为在这之后,我有另一个模型以确切的方式保存数据,它不会松手。
It's weird, cause right after this, I have another model saving data to it in the exact same fashion, it goes off without a hitch.
推荐答案
这可能会给你你需要的信息(假设它不是保存,因为无效的数据,当然):
This will probably give you the info you need (assuming it's not saving because of invalid data, of course):
if(!$this->save()){
debug($this->validationErrors); die();
}
这篇关于save()返回false,但在CakePHP中没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!