title: Codeigniter, "call to a member function get() on a non-object" error only from the model
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12024468/call-to-a-member-function-get-on-a-non-object">Call to a member function get() on a non-object</a>  </p>
  </blockquote>
  
  
  
  <p>I autoload the database library.</p>
  
  <p>Here is my Controller</p>
  
  <pre><code>class Orders extends CI_Controller {
  
  public function __construct()
  {
      parent::__construct();
      $this-&gt;load-&gt;model('orders_model');
  
  }
  
  public function index()
  {
      echo $this-&gt;orders_model-&gt;test();
      $data['orders'] = $this-&gt;orders_model-&gt;get_orders();
  </code></pre>
  
  <p>and here is my Model</p>
  
  <pre><code>class Orders_model extends CI_Model {
  
  public function __construct()
  {
      parent::__construct();
  
  
  }
  
  public function get_orders($slug = FALSE)
  {
  
  if ($slug === FALSE)
      {
  
          $query = $this-&gt;db-&gt;get('table1');
          return $query-&gt;result_array();
      }
  
  
      $query = $this-&gt;db-&gt;get_where('table1', array('numtest' =&gt; $slug));
      return $query-&gt;row_array();
  
  }
  public function test()
  {
      $text = "return test";
      return $text;
  }
  </code></pre>
  
  <p>For troubleshooting purposes I moved the code from the model to the controller executed the code successfully. Somehow though, it does not function when I try and do the get() call from my Model. Also, calling the test() function from within the Model works successfully.</p>