diff options
author | joelcox <joel@mickly.com> | 2011-01-16 15:00:04 +0100 |
---|---|---|
committer | joelcox <joel@mickly.com> | 2011-01-16 15:00:04 +0100 |
commit | e3da4283b8b0aa96ee6f877c85c62d05dea8c778 (patch) | |
tree | f82144aaf952169c1f83821ba1c80410865d70a0 /system/database | |
parent | 96b72ae4dc1334431f95d3f3151409f656a19725 (diff) |
Changed loading process for database config to check for config for the set environment first.
Diffstat (limited to 'system/database')
-rw-r--r-- | system/database/DB.php | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/system/database/DB.php b/system/database/DB.php index 60a67e821..739e9d08e 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -27,7 +27,21 @@ function &DB($params = '', $active_record_override = NULL) // Load the DB config file if a DSN string wasn't passed if (is_string($params) AND strpos($params, '://') === FALSE) { - include(APPPATH.'config/database'.EXT); + + $file_path = APPPATH.'config/'.ENVIRONMENT.'/database'.EXT; + + if ( ! file_exists($file_path)) + { + log_message('debug', 'Database config for '.ENVIRONMENT.' environment is not found. Trying global config.'); + $file_path = APPPATH.'config/database'.EXT; + + if ( ! file_exists($file_path)) + { + continue; + } + } + + include($file_path); if ( ! isset($db) OR count($db) == 0) { |