我需要运行与此类似的查询
select * from users where (username='abc' or email='[email protected]') and password='123'
如何在 codeigniter 中做到这一点?我尝试过类似的事情,
$this->db->select('*');
$this->db->from('users');
$this->db->where("email = '" . $email . "'");
$this->db->or_where("username = '" . $email . "'");
$this->db->where("password = '" . $password . "'");
$query = $this->db->get();
用户可以在此处插入用户名值,例如电子邮件或用户名。因此需要检查电子邮件字段和带有密码的用户名字段中的用户名字段值
试试这个
$this->db->from('users');
$this->db->where("(email = '" . $email . "' OR username = '" . $email . "') ");
$this->db->where("password = '" . $password . "'");
这应该有效
$this->db->where("(username='abc' or email='[email protected]')");