Welcome Guest, Not a member yet? Register   Sign In
Accessing the Database Configuration Array
#1

[eluser]NotoriousWebmaster[/eluser]
I'm writing a utility app which allows the admin to perform tasks on different instances of the database by selecting the DB in the form (radio buttons). Based on this selection, the controller needs to load the model with the given DB's config array.

This DB config array is already defined in the database.php config file. Is there some way to access this array from the controller?

Thanks for your help,
- AAA
#2

[eluser]InsiteFX[/eluser]
CodeIgniter User Guide - Config Class

InsiteFX
#3

[eluser]NotoriousWebmaster[/eluser]
Thx for the quick reply InsiteFX. In fact, I did dump the $this->config object from the controller to see if it contained what I was looking for. It didn't.

But reviewing the docs for the config class I'm thinking I could save the db array in the config/database.php file, to the config class. Then access it from the controller.

This'll work for now. Please let me know if there's a better way to do this.

Thx again,
- AAA
#4

[eluser]InsiteFX[/eluser]
Yep, I just checked they are including the database.php file!

You could include the database.php file yourself and then access.
Code:
include(APPPATH.'config/database.php')

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB