CodeIgniter Forums
using values from config in the db 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: using values from config in the db config file (/showthread.php?tid=14350)



using values from config in the db config file - El Forum - 12-30-2008

[eluser]cwpollock[/eluser]
I'm trying to centralize the change in configuration information into one file.

I want to set the db configuration along this lines

Code:
$db['default']['database'] = $this->config->item("db_name");

When I tried this it tells me that "this" is not available in this context.

Any thoughts on how to do this?


using values from config in the db config file - El Forum - 12-30-2008

[eluser]xwero[/eluser]
It seems a bit weird to import config settings in a config file. This also means there can only be one database group.

But a way to do it is just to include the one file, get the settings you need and destroy the rest
Code:
include(APPPATH'config/config.php');
$db = $config['db'];
unset($config);



using values from config in the db config file - El Forum - 12-30-2008

[eluser]cwpollock[/eluser]
Thanks that suits my purpose just fine.