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
class Report extends MY_Controller{
public function item_ladger()
{
$material = $this->Material_Model->get(); // when i call it here it works fine
$inventory = $this->db->query("CALL inventory($id)")->result_array();
$material = $this->Material_Model->get(); // when i call it here it Generate Fatal error: Call to a member function result() on a non-object in
}
}
what's the reason behind?
EDIT
this is my material model it has table name and all table fields
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;
}
this is my MY_Model it has table name and get method to get all result
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->db->order_by($this::DB_TABLE_PK, 'DESC')->get($this::DB_TABLE, $limit, $offset);
else
$query = $this->db->get($this::DB_TABLE, $limit, $offset);
}
else {
$query = $this->db->get($this::DB_TABLE);
}
$ret_val = array();
$class = get_class($this);
foreach ($query->result() as $row) {
$model = new $class;
$model->populate($row);
$ret_val[$row->{$this::DB_TABLE_PK}] = $model;
}
return $ret_val;
}