title: codeigniter active record where, or_where?
body: <p>I am using Active Record on CodeIgniter. I am confused on which approach I should take. Currently, our login system let's the user to use username/email for the login along with the password. But my current active record, seems to let the user logged in if he choose to use the email + no password.</p>
  
  <p>Right now this is my query:</p>
  
  <pre><code>$this-&gt;db-&gt;select('id,level,email,username');
  $this-&gt;db-&gt;where('email',$user);
  $this-&gt;db-&gt;or_where('username',$user);
  $this-&gt;db-&gt;where('password',$pass);
  $query = $this-&gt;db-&gt;get('users');
  
  if($query-&gt;num_rows&gt;0)
    return TRUE;
  else
    return FALSE;
  </code></pre>
  
  <p>Sample inputs:</p>
  
  <ul>
  <li>Username: <strong>test</strong> | Password: <strong>pass</strong> | Result: <strong><em>Success</em></strong></li>
  <li>Username: <strong>test</strong> | Password: <em>empty</em> | Result: <strong><em>Failed</em></strong></li>
  <li>Username: <strong>test@domain.com</strong> | Password: <strong>pass</strong> | Result: <strong><em>Success</em></strong></li>
  <li>Username: <strong>test@domain.com</strong> | Password: <em>empty</em> | Result: <strong><em>Success</em></strong></li>
  </ul>
  
  <p>The fourth test input must be <strong><em>Failed</em></strong> in result, but it seems that it logs the user even if the password is empty.</p>