Is it Allowed to Make loading of Resources Global to a controller? |
[eluser]n00bPhpCoder[/eluser]
instead of loading them via functions can we do this? say function index(){ $this->load->model('downloadmodel','dl'); $data['downloads']=$this->dl->getEntries(2); $this->load->view('home',$data); } instead of loading the model in index function i need to load it globally so that other functions can use the model too. like can i load it on constructor function Home() { parent::Controller(); $this->load->model('downloadmodel','dl'); } so that the model object is also available on other functions? function no1{ $this->dl->something } function no2{ $this->dl->something } Any Ideas?
[eluser]Derek Allard[/eluser]
Currently models cannot be autoloaded, but it does seem like that would be useful.
[eluser]n00bPhpCoder[/eluser]
Right i was still thinking of Windows Programming . Im a bit new to CI so if ever my ways is not right pls correct me. BTW, does CI auto unload objects i created on the process? or i have to manually unload models i created?
[eluser]Derek Allard[/eluser]
No need to unload anything - resource allocation is handled pretty well. Oh yeah, and welcome to CodeIgniter!
[eluser]n00bPhpCoder[/eluser]
Wow I am really Impress with it you can see here what ive done using code igniter. Still exploring tons of possiblities using CI http://121.97.156.37
[eluser]marcoss[/eluser]
[quote author="n00bPhpCoder" date="1184569242"]instead of loading them via functions can we do this? Any Ideas?[/quote] If you mean loading the Model in the controller constructor, that's perfectly fine, i use it like this. Code: <?php |
Welcome Guest, Not a member yet? Register Sign In |