Codeigniter has methos to access and manage CURRENT configured database.
SPANISH version of this : https://groups.google.com/forum/m/#!topic/venenuxsarisari/jTP0zhLQHOY
There's no method to change on the fly the "current selected db group", u must create one group per database and select it on the load, such as:
where configdb1 its a stored array of database settings for connecting.
There's a hack 2way to dinamically choose database on the fly in the controller with one configuration.
1) configure a database group array but only in the config.php file
2) load all the varables and extrac the array of u'r db configuratio
3) change the "database" key value to the new
4) re - load the database library with the "changed" settings
a example quick code:
1) go to application/config.php :
$config['sysdb'] = array(
'database'=>'', /* this will be changed "on the fly" in controler */
2) now in u'r controller made "each time u want to change" a database name with same connections parameters:
$configdbfly = $this->config->config['sysdb'];
$configdbfly['database']='sysdbadminis'; /*cambiamos de db*/
IMPORTANT: the undocumented "$this->config->config" are subject to change and could not be available at the lasted version, but the item can be acceced manually.