CodeIgniter Forums
where problem (OR instead of AND) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: where problem (OR instead of AND) (/showthread.php?tid=45541)



where problem (OR instead of AND) - El Forum - 09-26-2011

[eluser]Unknown[/eluser]
In CodeIngiter User guide ,they said the following code:
Code:
$this->db->where('name', $name);
$this->db->where('title', $title);
$this->db->where('status', $status);
// WHERE name = 'Joe' AND title = 'boss' AND status = 'active'
It means when I wanna select some thing from database by active record,I should use where method and it will do it by replace AND between fields. now I wanna to make login page,I do this:

Code:
public function True_login($username = '',$password = '')
    {
        $this->db->flush_cache();
        $this->db->where('username',$username);
        $this->db->where('password',$password);
        $count = $this->db->count_all_results('PM_ADMIN_LIST');
        if ($count === 1)
        {
            return TRUE;
        }
        else
        {
            return FALSE;
        }
    }
but it will return TRUE if username=$username OR password = $password . if one of the username or password will be found in table(and $count === 1 it will return TRUE) where is my prbolem and how should I solve it?