我的代码
// 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。
希望这会有所帮助!!
关于mysql - Codeigniter 数据库检索大写、小写和混合大小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38940865/