![]() |
Loading 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: Loading Models (/showthread.php?tid=12593) |
Loading Models - El Forum - 10-24-2008 [eluser]rob897[/eluser] I have a couple models for this application and just noticed I needed to call one of the functions from another model... dbs_model Code: class DBS_Model extends Model { account_model Code: class Account_Model extends Model { Do these conflict each other as each one calls the other? I have tried to autoload all my models in the config, but the one function within the dbs_model fails with the following error: Code: Severity: Notice I know this may look confusing but I hit a dead end here and I not sure why I simple just couldn't load the dbs_model and call its function within the account_model.. If I leave the load dbs_model in the constructor, one of the functions with the account model actually prompts me to download a binary file... and as soon as I comment out the load dbs_model it works fine... Help!! Loading Models - El Forum - 10-27-2008 [eluser]rob897[/eluser] From what I read, you shouldn't load models within models, they should be loaded from the controller... so I will see if I can fix my coding to leave out any models that load more models.... but I really need some help here. -rob Loading Models - El Forum - 10-27-2008 [eluser]sl3dg3hamm3r[/eluser] I also would suggest you need to redesign it somehow. Two classes (or in that case models) who associate each other, that's a weird constellation... Loading Models - El Forum - 10-27-2008 [eluser]rob897[/eluser] So lets say I have this: Code: class Account extends Controller { So I should be able to call any of the dbs_model function from within this controller. I think my problem is that I am trying to call dbs_model->Backup() within the account_model itself. I think I get it but just want to make sure. -rob Loading Models - El Forum - 10-27-2008 [eluser]sl3dg3hamm3r[/eluser] [quote author="rob897" date="1225138286"]Can I assume that all the functions within the other models loaded are available throughout this entire controller?[/quote] Jep, that's right. Loading Models - El Forum - 10-27-2008 [eluser]rob897[/eluser] So then with this controller Code: <?php Within the "accounts_model" class there are functions that return account information, I think I am accessing these directly from the model and not the controller so for instance, I have in the dbs_model something that returns: Code: $this->account_model->SearchAccounts($domain); |