Welcome Guest, Not a member yet? Register   Sign In
loading libraries and models from within a model
#7

[eluser]rayray[/eluser]
It's easy to load models inside of models similar to loading them in a controller, but once loaded you must instantiate them (unless all you want to access is static members/methods). You can use the following from inside a model:

Code:
$this->load->model('SomeObjectModel');
$object = new SomeObjectModel();

You get this functionality because when the controller loads a model, it also assigns references to all it's currently instantiated objects. In the example above, you're using an instance of the Loader class which the is referenced in the controller with
Code:
$this->load
.

Given a non-trival schema, I can see many places how you'd want to access an model object inside another model.


Messages In This Thread
loading libraries and models from within a model - by El Forum - 03-24-2009, 03:39 AM
loading libraries and models from within a model - by El Forum - 03-24-2009, 03:55 AM
loading libraries and models from within a model - by El Forum - 03-24-2009, 04:00 AM
loading libraries and models from within a model - by El Forum - 03-24-2009, 04:13 AM
loading libraries and models from within a model - by El Forum - 03-24-2009, 04:14 AM
loading libraries and models from within a model - by El Forum - 03-24-2009, 04:17 AM
loading libraries and models from within a model - by El Forum - 04-14-2009, 09:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB