From e3da4283b8b0aa96ee6f877c85c62d05dea8c778 Mon Sep 17 00:00:00 2001 From: joelcox Date: Sun, 16 Jan 2011 15:00:04 +0100 Subject: Changed loading process for database config to check for config for the set environment first. --- system/database/DB.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'system/database/DB.php') 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) { -- cgit v1.2.3-24-g4f1b From c3a4a8d973b9c0a7cc935d150b8b1c6898037c45 Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Mon, 14 Feb 2011 13:40:08 -0500 Subject: Whitespace cleanup in db classes --- system/database/DB.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index 513e5aefd..93ee3922a 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -88,7 +88,7 @@ function &DB($params = '', $active_record_override = NULL) { parse_str($dns['query'], $extra); - foreach($extra as $key => $val) + foreach ($extra as $key => $val) { // booleans please if (strtoupper($val) == "TRUE") -- cgit v1.2.3-24-g4f1b