CodeIgniter Forums
database driver config file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: database driver config file (/thread-32669.html)



database driver config file - El Forum - 07-30-2010

[eluser]ranjudsokomora[/eluser]
Hello CI Coders,
I was wondering if there was a way to make ./system/application/config/config.php database driven. I am writing an application in CI that can handle more than one website on a single CI application installation. The problem with this is that I need to change configuration values based on the user's website.

Any ideas?


database driver config file - El Forum - 07-30-2010

[eluser]WanWizard[/eluser]
Depends on what you want to modify.

You don't have the database and full CI functions available until the constructor of your (MY) controller (actually, as of the post-controller-hook). Some of the config values are used by the classes that are loaded as part of the startup process, like URI, Router, Input, and Output.


database driver config file - El Forum - 08-02-2010

[eluser]ranjudsokomora[/eluser]
I want to modify every value of the config file. That is why I need the database. I have successfully done this by rewriting the ./system/libraries/router.php, however I wanted to do in ./system/libraries/config.php any ideas?


database driver config file - El Forum - 08-02-2010

[eluser]danmontgomery[/eluser]
You're rewriting system files? Yikes...

You can load these values post-controller-constructor like WanWizard suggests, or load the database in a pre-system hook, or just put it in the constructor of a MY_Controller... Almost any solution is a better one than rewriting system files.