title: Fatal error: Call to a member function result() on a non-object in Codeigniter
body: <p>Fatal error: Call to a member function result() on a non-object in D:\wamp\www\ocss\application\core\My_Model.php on line 111</p>
  
  <pre><code>class Report extends MY_Controller{
      public function item_ladger()
      {
          $material = $this-&gt;Material_Model-&gt;get(); // when i call it here it works fine
          $inventory = $this-&gt;db-&gt;query("CALL inventory($id)")-&gt;result_array();
          $material = $this-&gt;Material_Model-&gt;get(); // when i call it here it Generate Fatal error: Call to a member function result() on a non-object in
      }
  }
  </code></pre>
  
  <p>what's the reason behind?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>this is my material model it has table name and all table fields</p>
  
  <pre><code>class Material_Model extends MY_Model
  {
      const DB_TABLE = 'material';
      const DB_TABLE_PK = 'material_id';
  
      public $material_id;
      public $material_name;
      public $size;
      public $rate;
  }
  </code></pre>
  
  <p>this is my MY_Model it has table name and get method to get all result</p>
  
  <pre><code>class MY_Model extends CI_Model {
      const DB_TABLE = 'abstract';
      const DB_TABLE_PK = 'abstract';
  
      public function get($limit = 500, $offset = 0,$desc=true) {
      if ($limit) {
          if ($desc)
              $query = $this-&gt;db-&gt;order_by($this::DB_TABLE_PK, 'DESC')-&gt;get($this::DB_TABLE, $limit, $offset);
          else
              $query = $this-&gt;db-&gt;get($this::DB_TABLE, $limit, $offset);
      }
      else {
          $query = $this-&gt;db-&gt;get($this::DB_TABLE);
      }
  
      $ret_val = array();
      $class = get_class($this);
  
      foreach ($query-&gt;result() as $row) {
          $model = new $class;
          $model-&gt;populate($row);
  
          $ret_val[$row-&gt;{$this::DB_TABLE_PK}] = $model;
      }
      return $ret_val;
  }
  </code></pre>