From 39b622db9bda38282a32bb45623da63efe685729 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Wed, 16 Jan 2008 21:10:09 +0000 Subject: Many new Active Record functions, and another whack of stuff --- system/database/DB.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'system/database/DB.php') diff --git a/system/database/DB.php b/system/database/DB.php index 9055a22c4..425c8077b 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -29,14 +29,22 @@ function &DB($params = '', $active_record = FALSE) { include(APPPATH.'config/database'.EXT); - $group = ($params == '') ? $active_group : $params; + if ( ! isset($db) OR count($db) == 0) + { + show_error('No database connection settings were found in the database config file.'); + } + + if ($params != '') + { + $active_group = $params; + } - if ( ! isset($db[$group])) + if ( ! isset($active_group) OR ! isset($db[$active_group])) { - show_error('You have specified an invalid database connection group: '.$group); + show_error('You have specified an invalid database connection group.'); } - $params = $db[$group]; + $params = $db[$active_group]; } // No DB specified yet? Beat them senseless... @@ -78,7 +86,13 @@ function &DB($params = '', $active_record = FALSE) // Instantiate the DB adapter $driver = 'CI_DB_'.$params['dbdriver'].'_driver'; - $DB =& new $driver($params); + $DB =& new $driver($params); + + if ($DB->autoinit == TRUE) + { + $DB->initialize(); + } + return $DB; } -- cgit v1.2.3-24-g4f1b