title: CodeIgniter Call to a member function get_where() on a non-object
body: <p>Im super new to codeigniter and am trying to figure out how to use the Models, ive used a MVP framework before but it was a bit different. I have the users controller, which initializes the model(I think I did it right), then the model has a function, that gets a row by email. </p>
  
  <p>The controller looks like:</p>
  
  <pre><code>class Users extends CI_Controller{
      public function login(){
          $this-&gt;load-&gt;model('users_model');
  
          $this-&gt;users_model-&gt;login('slavigne@uark.edu', 'abcdefg');
  
          $this-&gt;load-&gt;view('templates/header');
          $this-&gt;load-&gt;view('users/login');
          $this-&gt;load-&gt;view('templates/footer');
      }
  }
  </code></pre>
  
  <p>and the model looks like:</p>
  
  <pre><code>class users_model extends CI_Model{
      public function users_model(){
              parent::__construct();
      }
  
      public function login($email, $password){
          $query = $this-&gt;db-&gt;get_where('users', array('email' =&gt; $email));
          return $query-&gt;result();
      }
  }
  </code></pre>
  
  <p>The problem im getting is:</p>
  
  <pre><code>Call to a member function get_where() on a non-object
  </code></pre>
  
  <p>which I understand means that db isn't an object, but all the code I saw for models, say that this should work. Any help or advice would be great! Also any advice on newbie mistakes to codeigniter would be nice! </p>