Fatal error: Call to a member function result() on a non-object

edited March 2014 in Bug Reports
My model is this:

class EmailTypes_model extends Base_module_model {

function __construct()
{
parent::__construct('email_types');
}

function get($id) {
$query = $this->db->get_where('email_types', array('id'=>$id));
return $query->row_array();
}
}

Which works fine when I access it from public facing controller. But then when I try to update a record via the fuelCMS admin it throws this error:
Fatal error: Call to a member function result() on a non-object in /Users/ben/Documents/htdocs/hp/hp-cxo-dcp/fuel/modules/fuel/core/MY_Model.php on line 675

What am I missing?

Thanks!

Comments

  • edited 9:50PM
    Try adding the following to your class if it is not already:
    public $record_class = 'EmailType';
    And make sure to add a record class below your EmailTypes_model class:
    class EmailType_model extends Base_module_record { }
    What may be happening is that FUEL is not finding a record class for you model and so it will return an array instead.
  • edited 9:50PM
    It didn't work. It's because the function is called get() - if I change the name it'll work - why would this be?
  • edited 9:50PM
    Oh... I didn't notice that. MY_Model has an important method already called "get" that you are overwriting.
Sign In or Register to comment.