Codeigniter 数据库以大写、小写和混合大小写检索

Codeigniter database retrieving both in uppercase, lowercase and mixed case

我的代码

// My code:

$this->db->select('*')
->from('tbl_login')
->where(['username'=>$this->input->post('username'),'password'=>$this->input->post('password')]);
$result = $this->db->get()->result();

if($result)
    var_dump($result)
else
    echo "not fount";

无论我输入什么 'admin1' 或 'ADMIN1' & 'password1' 或 'PASSWORD1' 它从表中检索数据。 但我真正想要的是当大小写匹配正确时将检索数据。

有人能帮忙吗???...

试试这个

  $query = $this->db->select("*")->from("tbl_login")->where("BINARY username= '".$this->input->post('username')."' and password = '".$this->input->post('password')."'");

  $result = $this->db->get()->result();

   if($result)
      var_dump($result)
   else
      echo "not found";

注意:基本上在查询中的 where 条件之前使用 BINARY

希望对您有所帮助!!