我是cakephp的新手所以我不知道如何在cakephp中编写此查询。有时我现在有这个查询
$count = $this->User->find('count', array(
'conditions' => array('User.mobileNo' => $mobileNo)));
此查询检查是否数据库中的手机号码等于用户给出的手机号码...我想添加另一个条件,即 手机号码等于用户提供的手机号码,电子邮件等于用户提供电子邮件的号码,例如
$count = $this->User->find('count', array(
'conditions' => array('User.mobileNo' => $mobileNo))) And
'conditions' => array('User.email' => $email)))
答案 0 :(得分:3)
您只需添加条件数组:
$count = $this->User->find('count', array(
'conditions' => array(
'User.mobileNo' => $mobileNo,
'User.email' => $email
)
));
文档e.g.中有很多这样的例子。
$conditions = array("Post.title" => "This is a post", "Post.author_id" => 1);
// Example usage with a model:
$this->Post->find('first', array('conditions' => $conditions));