![]() |
Autoload model with usage of autoloaded libraries - 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: Autoload model with usage of autoloaded libraries (/showthread.php?tid=3926) |
Autoload model with usage of autoloaded libraries - El Forum - 10-29-2007 [eluser]Escee[/eluser] Hi y'all, I'm quite new to CodeIgniter, and I'm stuck, that's why I'm here ;-) I managed to autoload models after tweaking the Loader.php file a bit, but the model that is autoloaded makes use of the session library which is autoloaded. When the model is autoloaded, the error occurs that the session library doesn't exist/isn't loaded. So my question, is there a way that models can be autoloaded so they can make use of the autoloaded libraries such as the session library? Thanks! :-) Stefan Autoload model with usage of autoloaded libraries - El Forum - 10-29-2007 [eluser]Derek Allard[/eluser] Welcome to CI Escee. I hope after this gets resolved for you we see you around a lot more ![]() Can you post some relevant chunks of your model so we can see how you are using the session? Autoload model with usage of autoloaded libraries - El Forum - 10-29-2007 [eluser]Escee[/eluser] &uot;[quote author="Derek Allard" date=;1193695204"]Welcome to CI Escee. I hope after this gets resolved for you we see you around a lot more ![]() Can you post some relevant chunks of your model so we can see how you are using the session?[/quote] Okay, for example, here is the constructor of the 'member' model which checks if a user is already logged in: Code: public function Member ( ) And here's a bit of code for a new login: Code: public function ProcessLogin ( $username, $password ) When I first load the session library and then the member model in a controller, it works. But i'd like to autoload them both (the session library already does). But when I autoload them both, the member won't find/use/load/... the session library.. Hope you understand :-) So far CodeIgniter rocks, great documentation, helps allot ;-) Stefan Autoload model with usage of autoloaded libraries - El Forum - 10-29-2007 [eluser]ELRafael[/eluser] Remmember one thing Stefan: If you autoload the model, it'll be avaible for all controllers. Even that controllers that won't use the model. But i can't see an error, sorry. I my case, i just autoload the session (and anothers) libraries. And i don't use $this->session inside models... i can be wrong, but i believe the function of a model is "talk" to database, not to talk another components. I don't know the order of auto load, but the logic is load model then load session library, so session is avaible in the model, right? Derek certainly can give you a better answer. And, for sure, a better writting than mine :-P Autoload model with usage of autoloaded libraries - El Forum - 10-29-2007 [eluser]Derek Allard[/eluser] Just a thought. Open up your system/libraries/Loader.php, and look for Code: // Autoload models try cutting that, and pasting it a few lines lower immediately after Code: // Load all other libraries so that now it looks like Code: // Load all other libraries Any help? Autoload model with usage of autoloaded libraries - El Forum - 10-29-2007 [eluser]Escee[/eluser] I tried that before, then it didn't work. Strange enough it does work now, just reversed the loop for autoloading libraries with the loop for plugins, helpers etc. ![]() Thanks for helping me out ![]() @ELRafael: [quote author="ELRafael" date="1193704278"]Remmember one thing Stefan: If you autoload the model, it'll be avaible for all controllers. Even that controllers that won't use the model. [..] I my case, i just autoload the session (and anothers) libraries. And i don't use $this->session inside models... i can be wrong, but i believe the function of a model is "talk" to database, not to talk another components. [..][/quote] This sounds okay, but when you have users logged on to your site, how would you handle there sessions and stuff without a model? Autoload model with usage of autoloaded libraries - El Forum - 10-29-2007 [eluser]Derek Allard[/eluser] My pleasure, glad you got it running, and welcome onboard! Autoload model with usage of autoloaded libraries - El Forum - 01-03-2008 [eluser]somewhatjaded[/eluser] i had the same problem, and this fixed it as well (I was trying to autoload the EzAuth model). |