codeigniter active record where, or_where?

前端 未结 3 1005
小蘑菇
小蘑菇 2021-01-12 14:55

I am using Active Record on CodeIgniter. I am confused on which approach I should take. Currently, our login system let\'s the user to use username/email for the login along

3条回答
  •  無奈伤痛
    2021-01-12 15:35

    The issue is probably that you need to add brackets when mixing AND’s and OR’s in a WHERE clause. Try this:

    $this->db->select('id,level,email,username');
    $this->db->where("(email = '$user' OR username = '$user') 
                       AND password = '$pass'");
    $query = $this->db->get('users');
    

提交回复
热议问题