Welcome Guest, Not a member yet? Register   Sign In
Extending CI_Model more than once in applications/core
#7

[eluser]glevine[/eluser]
How is CI_Model not in a common CI's structure? CI_Model is the base model class for CI, located in system/core. As long as you don't replace it, it is loaded for every request.

All that said, I looked at how CI loads models. Every time you call $this->load->model('foo'); you get the same instance of Foo. So if you need multiple instances of Foo in a single request, then loading the model isn't really what you want.

It's like CI models are inherently singletons, just written in a weird way. When the model is loaded the first time, the name of the model is added to Loader::_ci_models and the CI super object ($CI) gets a property that references the instantiated object. After that, anytime you load the model again during the same request, you are referencing the same object.

So really, my Peer class should inherit from CI_Model and my models should become a new class hierarchy that simply stores the state of an object. The Peer classes can directly include the object class that they support.


Messages In This Thread
Extending CI_Model more than once in applications/core - by El Forum - 03-12-2012, 09:56 PM
Extending CI_Model more than once in applications/core - by El Forum - 03-12-2012, 10:15 PM
Extending CI_Model more than once in applications/core - by El Forum - 03-12-2012, 10:29 PM
Extending CI_Model more than once in applications/core - by El Forum - 03-12-2012, 10:31 PM
Extending CI_Model more than once in applications/core - by El Forum - 03-12-2012, 10:37 PM
Extending CI_Model more than once in applications/core - by El Forum - 03-12-2012, 10:43 PM
Extending CI_Model more than once in applications/core - by El Forum - 03-12-2012, 11:08 PM
Extending CI_Model more than once in applications/core - by El Forum - 03-13-2012, 12:09 AM
Extending CI_Model more than once in applications/core - by El Forum - 03-13-2012, 01:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB