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

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,

CodeIgniter User Guide - Config Class


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,

Yep, I just checked they are including the database.php file!

You could include the database.php file yourself and then access.


Theme © iAndrew 2016 - Forum software by © MyBB