Welcome Guest, Not a member yet? Register   Sign In
Loading multiple models in a controller, which extend the same base class.
#2

[eluser]drewbee[/eluser]
You can extend the base model class as many times as you like because it is only been declared once, but initiated many times.

Declared = file has been loaded through a require/include etc.
Initiated = class has been initiated into an instance of the class and assigned a var.

For your include, you simply need to check and see if the class has been loaded yet:
I believe class_exists checks against declared classes, so you should be able to use that:


replace:
Code:
include dirname(__FILE__)."/ma_model.php";

With:

Code:
if (!class_exists('MA_Model', false))
{
    include dirname(__FILE__)."/ma_model.php";
}

Now you should just have to put this on each of your files where you want to use multiple models in the same controller.


Messages In This Thread
Loading multiple models in a controller, which extend the same base class. - by El Forum - 05-07-2009, 11:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB