Welcome Guest, Not a member yet? Register   Sign In
Loading Models in __construct
#1

[eluser]CI_Newb[/eluser]
If I have a controller that has 20 functions in it and 15 of those all require the same model.

Is it better to load it in the __construct in the controller or in each individual function?

Don't need it enough to warrant autoloading it though.
#2

[eluser]cahva[/eluser]
Yes, constructor is the right place to load the model if its used in majority of methods in that controller.
Use $this->ouput->enable_profiler() to see how much it affects memory usage and load time when model is loaded/not loaded. The difference usually is so minimal that it doesnt matter.
#3

[eluser]CI_Newb[/eluser]
Awesome stuff, thanks for the info!




Theme © iAndrew 2016 - Forum software by © MyBB