CodeIgniter Forums
Access database config file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Access database config file (/showthread.php?tid=44813)



Access database config file - El Forum - 08-27-2011

[eluser]Unknown[/eluser]
I am trying to access the database config file from a model. I've tried things like:
Code:
$this->config->item('hostname');
$this->config->load('database', TRUE));
$db_hostname = $this->config->item('hostname', 'database');

But no matter how hard I try I can't access the parameters.

Here is why I want to access these parameters: I got 'root' login on my MySQL system, there are about 150 databases on this system which I want to manage by 1 project in code igniter. So basicly I only want to switch to another database with the same connection parameters (username, password, host).

Ideally, something like this would be great:
Code:
$this->db->selectdb('other dbname');


Options like 150 groups in the database config file isn't really a option. So the only thing left is to access the above mentioned parameters and do a manual connection.

Any smart suggestions?