Welcome Guest, Not a member yet? Register   Sign In
Application Config Files in Controllers
#1

[eluser]jtkendall[/eluser]
Hi, I'm working on a project where the user needs to be able to change certain config settings. One of the config settings that the user needs to be able to change is the database connection information. I want them to be able to modify this information through a web form instead of actually worrying about editing a PHP file.

Is there a way in CI to load the system's database.php config file like a regular PHP include() so I can access the $db array? Or can someone recommend a way of doing what I need?

Thanks,
#2

[eluser]jtkendall[/eluser]
I have it working using:

Code:
include($_SERVER['DOCUMENT_ROOT'].'/system/application/config/database.php');

(tried this earlier and just forgot to use DOCUMENT_ROOT)

I'm still interested in knowing if there is a better/proper way of doing this in CI.
#3

[eluser]wiredesignz[/eluser]
Code:
include APPPATH.'config/database.php';  //include is not a php function() it is a php directive.
#4

[eluser]jtkendall[/eluser]
Thanks wiredesignz APPPATH certainly makes it quicker to type.
#5

[eluser]Colin Williams[/eluser]
Yep. It's PHP. You can do anything you see here: http://www.php.net/manual/en/langref.php




Theme © iAndrew 2016 - Forum software by © MyBB