shavindip
shavindip

Reputation: 622

Codeigniter database make case sensitive

I need to consider case sensitivity when login to my system. But password do not consider case.

    $this->db->select('user.*,userprofile.*,user.id as uid');
    $this->db->from('user');
    $this->db->join('userprofile', 'userprofile.id = user.id');
    $this->db->like('email', $udata['email']);
    $this->db->like('password', $udata["password"]);
    $query = $this->db->get();

The above is my query. How can I change it so that its case sensitive?

Upvotes: 0

Views: 967

Answers (2)

shavindip
shavindip

Reputation: 622

I changes my variables names to get the two separately and used LIKE inside 'where'.

I changes this :

$this->db->like('password', $udata["password"]);

to

$this->db->where('password LIKE binary', $password);

Upvotes: 1

Atural
Atural

Reputation: 5439

a possible approach could be

$this->db
    ->select('user.*,userprofile.*,user.id as uid')
    ->from('user')
    ->join('userprofile', 'userprofile.id = user.id')
    ->where('email', $udata['email'])
    ->where('BINARY password =', $this->db->escape($udata["password"]), false)
    ->get();

For more information take a look here

Upvotes: 1

Related Questions