Welcome Guest, Not a member yet? Register   Sign In
FIXED: Loading a model from inside another model.
#1

[eluser]louis w[/eluser]
In some cases, I need my model to load another model and fetch some info before returning it all to the controller.

The name of the sub-model needs to be dynamic, as it will be coming from the db row.

This is the code I am trying in my model.

Code:
if (!is_object('$this->'.$module.'_model'))
     $this->load->model($module.'_model');

$module_item = $this->{$module.'_model'}->getByID($row[$this->id_field]);

I get this error:
Message: Undefined property: A_model::$b_model (i changed the variable names)


This was developed under PHP5 and I do not care about backwards compatibility with 4.


Messages In This Thread
FIXED: Loading a model from inside another model. - by El Forum - 06-03-2008, 09:23 AM
FIXED: Loading a model from inside another model. - by El Forum - 06-03-2008, 09:31 AM
FIXED: Loading a model from inside another model. - by El Forum - 06-03-2008, 03:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB