title: Call to a member function get() on null error
body: <p>I keep getting this error in CodeIgniter-2.2.1.(Fatal error: Call to a member function get() on null in C:\xampp\htdocs\ci\application\models\site_model.php on line 6) I am not sure why this is happening. Am I calling the function correctly? Line 6 is $this->load->model('site_model');</p>
  
  <p>controller site.php</p>
  
  <pre><code>&lt;?php
   class Site extends CI_Controller{
  function index(){
      $this-&gt;load-&gt;model('site_model');
      $data['records'] = $this-&gt;site_model-&gt;getAll();
      $this-&gt;load-&gt;view('home', $data);
      }}
  </code></pre>
  
  <p>site_model.php </p>
  
  <pre><code>&lt;?php
  class Site_model extends CI_Model{
  
    function getAll(){
  
      $q = $this-&gt;db-&gt;get('test');
      if($q-&gt;num_rows() &gt;0){
      foreach ($q-&gt;result() as $row)
      {
       $data[] =$row;
      }
       return $data;
     }
   }
  }
  ?&gt;
  </code></pre>
  
  <p>home.php The view page</p>
  
  <pre><code>&lt;!DOCTYPE&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Site&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="container"&gt;
          &lt;p&gt;My view has been loaded&lt;/p&gt;
      &lt;pre&gt;
  
  &lt;?php print_r($records);?&gt;
      &lt;/pre&gt;
  
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>