我需要运行类似于此
的查询select * from users where (username='abc' or email='abc@gmail.com') 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();
此处,用户可以将用户名的值插入电子邮件或用户名。因此,需要在电子邮件字段和用户名字段中使用密码
检查用户名字段值答案 0 :(得分:2)
这应该有效
$this->db->where("(username='abc' or email='abc@gmail.com')");
答案 1 :(得分:2)
试试这个
$this->db->from('users');
$this->db->where("(email = '" . $email . "' OR username = '" . $email . "') ");
$this->db->where("password = '" . $password . "'");