summaryrefslogtreecommitdiffstats
path: root/system/database/DB.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/database/DB.php')
-rw-r--r--system/database/DB.php16
1 files changed, 15 insertions, 1 deletions
diff --git a/system/database/DB.php b/system/database/DB.php
index fb0516ba4..513e5aefd 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)
{