CodeIgniter Forums

Full Version: Get $active_group?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Jonas G[/eluser]
Quick question: Is it possible to get the $active_group defined in databases.php somehow?

El Forum

[eluser]TheFuzzy0ne[/eluser]
I don't think there's any sensible way to do it, other than to do this:

Code:
include(APPPATH . 'config/database.php');

Then the $active_group variable will be available in the scope of the function where the file was included.

El Forum

[eluser]Colin Williams[/eluser]
I would print_r($this->db) and hunt for it. Might be somewhere in there.

El Forum

[eluser]TheFuzzy0ne[/eluser]
No such luck I'm afraid...

El Forum

[eluser]Dam1an[/eluser]
Could you not do something like
Config:
Code:
$config['active_group'] = "default";

Database:
Code:
$active_record = $this->config->item('active_group');

And then you can just get the value via the config class
(Note: This has not been tested, but should work non the less)

El Forum

[eluser]Rob Corley[/eluser]
I just tried the above, and just for reference you need to do:-

Code:
$CI =& get_instance();
$active_group = $CI->config->item('active_group');

Inside database.php to be able to access the config variables.