Best place for loading web app settings from database |
Hi everyone! Simple question
What if I save some site settings in database, so where would be the best place for autoload it? By now I ovveride CI_Loader function initialize PHP Code: public function initialize() What u thinking about that? Thanks!
Extend the core Loader, in application/core/MY_Loader, or else make a base controller, application/core/MY_Controller.
Don't modify system/core/Loader.
What kind of settings are you saving in your database?
As @ciadmin says, don't modify the system/core/Loader class because the next time you update the framework, you might ending overriding your own changes. Anyway, you could also use Hooks. Or, if it fits, create an autoloaded helper function just to load the configurations on demand.
Best regards,
José Postiga Senior Backend Developer
Hi scion,
I did that for a project one day. I created a config_model, and extended the CI_Controller with my own controller (in the core folder C.F. MY_Controller) see http://www.codeigniter.com/user_guide/ge...asses.html PHP Code: class MY_Controller extends CI_Controller { after that, $config can be accessible by a $this->config if your controller extend MY_Controller and not CI_Controller i'm agree with josepostiga. "DON'T TOUCH THE SYSTEM'S FOLDER !!!!!" ![]() |
Welcome Guest, Not a member yet? Register Sign In |