I want to use following query in Codeigniter:
SELECT `users` . * , `users_profile` . * FROM (`users`) LEFT JOIN `users_profile`
ON `users`.`id` = `users_profile`.`users_id`
WHERE (`loginid` = '$username' OR `email` = '$username' )
AND `password` = '$password' AND `users`.`status` = 'A' LIMIT 1
It is working fine, but when I write this query in Codeigniter format:
$this->db->where('loginid',"$username");
$this->db->or_where('email', "$username");
$this->db->where('password',MD5($password));
$this->db->where('users.status','A');
$this->db->limit(1);
It will return always true what is right syntax?
You should use the custom string method of where() as this is not possible directly with only ActiveRecord. See this link from the documentation and scroll to the 4th option under the where() function.
Example: