Welcome Guest, Not a member yet? Register   Sign In
Loading model inside a model
#1

[eluser]asprillia[/eluser]
I try to load a model inside another model, but the model is not loaded in $this, but probably in $ci.
I've come up with this solution that seems more like a hack. How else can I solve this.

example:
Code:
<?
class MyModel extends Model {
function test() {
   $this->load->model('Another_model');
   $this->Another_model->insert();//$this->Another_model si not defined
   $this->_assign_libraries();//now it is
   $this->Another_model->insert();//works
//or
   $ci = get_instance();
   $ci->Another_model->insert();
}

}
Should "Another_model" be in the model object, since it lets me load it?


Messages In This Thread
Loading model inside a model - by El Forum - 05-14-2008, 07:48 AM
Loading model inside a model - by El Forum - 05-14-2008, 08:56 AM
Loading model inside a model - by El Forum - 05-14-2008, 09:39 AM
Loading model inside a model - by El Forum - 05-14-2008, 12:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB