summaryrefslogtreecommitdiffstats
path: root/system/database/DB.php
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2008-01-16 22:10:09 +0100
committerDerek Allard <derek.allard@ellislab.com>2008-01-16 22:10:09 +0100
commit39b622db9bda38282a32bb45623da63efe685729 (patch)
tree0d1a1729dc544ebfd1d3dfb11b2ff78759bcf7be /system/database/DB.php
parentf4615fec22671262e95d3a852f8b9088314118f2 (diff)
Many new Active Record functions, and another whack of stuff
Diffstat (limited to 'system/database/DB.php')
-rw-r--r--system/database/DB.php24
1 files changed, 19 insertions, 5 deletions
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;
}