summaryrefslogtreecommitdiffstats
path: root/system/database/DB.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-06-23 19:51:47 +0200
committerAndrey Andreev <narf@bofh.bg>2012-06-23 19:51:47 +0200
commit3345ee5133e6cf83506a46b306b3df18cba14b0e (patch)
tree5f63b285702b30d953352e632b0f63be6e7b03c8 /system/database/DB.php
parentfbba54ea6c896e0545d4d20a19abe06d57ffc97b (diff)
Alter DB() to check if a subdriver is available
Diffstat (limited to 'system/database/DB.php')
-rw-r--r--system/database/DB.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/system/database/DB.php b/system/database/DB.php
index 00d14b43e..638b51bdd 100644
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -144,7 +144,10 @@ function &DB($params = '', $query_builder_override = NULL)
// Load the DB driver
$driver_file = BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php';
- if ( ! file_exists($driver_file)) show_error('Invalid DB driver');
+ if ( ! file_exists($driver_file))
+ {
+ show_error('Invalid DB driver');
+ }
require_once($driver_file);
@@ -152,6 +155,19 @@ function &DB($params = '', $query_builder_override = NULL)
$driver = 'CI_DB_'.$params['dbdriver'].'_driver';
$DB = new $driver($params);
+ // Check for a subdriver
+ if ( ! empty($DB->subdriver) && empty($params['subdriver']))
+ {
+ $driver_file = BASEPATH.'database/drivers/'.$param['dbdriver'].'/subdrivers/'.$params['dbdriver'].'_'.$params['subdriver'].'_driver.php';
+
+ if (file_exists($driver_file))
+ {
+ require_once($driver_file);
+ $driver = 'CI_DB_'.$params['dbdriver'].'_'.$params['subdriver'].'_driver';
+ $DB = new $driver($params);
+ }
+ }
+
if ($DB->autoinit === TRUE)
{
$DB->initialize();