我正在使用phalcon框架,我想执行此查询
public function updateAction($id)
{
$email = $this->request->getPost('email');
$check_email_unique = Users::find(['conditions' => 'id != ' .$id. ' AND email = '. $email]);
echo $check_email_unique->id;
return ;
}
答案 0 :(得分:2)
您希望绑定参数,因为您正在执行的操作容易受到SQL注入的攻击。</ p>
尝试一下:
$check_email_unique = Users::findFirst([
'conditions' => "email = :email: AND id != :id:",
'bind' => [
'email' => $email,
'id' => $id
]
]);
答案 1 :(得分:0)
谢谢..我这样解决了我的问题:
public function updateAction($id)
{
$email = $this->request->getPost('email');
$check_email_unique = Users::findFirst(['conditions' => "email = '".$email."' AND id != '".$id."'"]);
echo $check_email_unique->id;
return ;
}