这是我的模型:尔康模型更新不工作
class Users extends Model
{
public $id;
public $fname;
public $lname;
public $email;
public $password;
public $emailVerified;
public $suspended;
}
,现在我要suspend
用户...
$user = Users::findFirst(
array(
'conditions' => "email=:email:",
'bind' => array(
'email' => $context->request->getPost("email")
))
);
$user->suspended = 1;
$user->save();
,现在来这里的问题后,我更新用户数据,suspended
字段按预期设置为1
,但奇怪的是emailVerified
字段也被更新。现在这两个字段的值都是:1
。
我不知道这是怎么发生的。我搜索了互联网,但无法找到类似的问题。难道我做错了什么?
更新:
这是mySQL日志。我发现了这个问题。 Phalcon查询构建器为emailVerified
创建的值包含在单引号中。所以它是一个字符串,字段类型是bit
。
111 Query
UPDATE `users` SET `fname` = 'user_fname', `lname` = 'user_lname', `email` = 'user_email', `emailVerified` = '0', `suspended` = 1 WHERE `id` = '3'
111 Quit
您的用户模型中是否有beforeValidation或beforeSave方法? –