CodeIgniter Forums
Loop? problem with loading Models within Models - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Loop? problem with loading Models within Models (/showthread.php?tid=27344)



Loop? problem with loading Models within Models - El Forum - 02-08-2010

[eluser]Unknown[/eluser]
I appologise if this is a stupid question, but I simply cannot work out what I need to do in this situation.

Basically, I have 2 models (let's call them Modela and Modelb) and I need to access some Modelb methods within Modela and vice versa.

I tried to load Modela from Modelb's consturctor and vice versa, but this causes fastcgi to bomb out with an error.

I am guessing this causes a loop of each model trying to load the other.

Is there some way to check a if model is currently loaded to use in an if(){} statement?

I tried to use
Code:
if (!isset(Modelb)){$this->load->model('Modelb')}
but it seems isset won't work with this.
Any ideas? Am I doing something fundamentally wrong here?


Edit: I'm really sorry - I just found another topic that deals with exactly this http://ellislab.com/forums/viewthread/142162/ . Guess I didn't search hard enough the first time. ^^