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.php37
1 files changed, 34 insertions, 3 deletions
diff --git a/system/database/DB.php b/system/database/DB.php
index 00d14b43e..d751325ce 100644
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -29,8 +29,8 @@
* Initialize the database
*
* @category Database
- * @author EllisLab Dev Team
- * @link http://codeigniter.com/user_guide/database/
+ * @author EllisLab Dev Team
+ * @link http://codeigniter.com/user_guide/database/
* @param string
* @param bool Determines if query builder should be used or not
*/
@@ -47,6 +47,21 @@ function &DB($params = '', $query_builder_override = NULL)
}
include($file_path);
+ //make packages contain database config files
+ foreach(get_instance()->load->get_package_paths() as $path)
+ {
+ if ($path !== APPPATH)
+ {
+ if (file_exists ($file_path = $path.'config/'.ENVIRONMENT.'/database.php'))
+ {
+ include ($file_path);
+ }
+ elseif ( file_exists ($file_path = $path.'config/database.php'))
+ {
+ include ($file_path);
+ }
+ }
+ }
if ( ! isset($db) OR count($db) === 0)
{
@@ -144,7 +159,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 +170,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))
+ {
+ $driver_file = BASEPATH.'database/drivers/'.$DB->dbdriver.'/subdrivers/'.$DB->dbdriver.'_'.$DB->subdriver.'_driver.php';
+
+ if (file_exists($driver_file))
+ {
+ require_once($driver_file);
+ $driver = 'CI_DB_'.$DB->dbdriver.'_'.$DB->subdriver.'_driver';
+ $DB = new $driver($params);
+ }
+ }
+
if ($DB->autoinit === TRUE)
{
$DB->initialize();