title: Call to a member function get() on a non-object
body: <p>I'm using the Codeigniter Framework and I'm getting the following error, </p>
  
  <blockquote>
    <p>call to a member function get() on a non-object in site_model.php on line 11 </p>
  </blockquote>
  
  <p>which is the row with the get() . test is the name of my table in my database. What am i doing wrong?</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);
          }
      }
  
  ?&gt;
  
  &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;
          }
      }
  </code></pre>