summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Controller.php46
-rw-r--r--system/libraries/Loader.php25
2 files changed, 68 insertions, 3 deletions
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index b91cf3b07..5fdbd9f9f 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -384,7 +384,7 @@ class Controller extends CI_Base {
require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver'.EXT);
// Instantiate the DB adapter
- $driver = 'CI_DB_'. $params['dbdriver'].'_driver';
+ $driver = 'CI_DB_'.$params['dbdriver'].'_driver';
$DB = new $driver($params);
if ($return === TRUE)
@@ -397,7 +397,49 @@ class Controller extends CI_Base {
$obj->db =& $DB;
}
// END _ci_init_database()
-
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize Database Utilities Class
+ *
+ * @access private
+ * @param mixed database platform
+ * @param bool whether to return the object
+ * @return void
+ */
+ function _ci_init_dbutils($db = '', $return = FALSE)
+ {
+ if ($this->_ci_is_loaded('dbutils') == TRUE AND $return == FALSE)
+ {
+ return;
+ }
+
+ if ($this->_ci_is_loaded('db') == FALSE)
+ {
+ $this->_ci_init_database();
+ }
+
+ require_once(BASEPATH.'database/DB_utility'.EXT);
+ require_once(BASEPATH.'database/drivers/'.$this->db->dbdriver.'/'.$this->db->dbdriver.'_utility'.EXT);
+
+
+ // Instantiate the DB adapter
+ $driver = 'CI_DB_'.$this->db->dbdriver.'_utility';
+ $DB = new $driver();
+
+ if ($return === TRUE)
+ {
+ return $DB;
+ }
+
+ $obj =& get_instance();
+ $obj->ci_is_loaded[] = 'dbutils';
+ $obj->dbutil =& $DB;
+ }
+ // END _ci_init_database()
+
// --------------------------------------------------------------------
/**
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index d966e2862..f4a9f821d 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -108,7 +108,7 @@ class CI_Loader {
* @param string the DB credentials
* @param bool whether to return the DB object
* @param bool whether to enable active record (this allows us to override the config setting)
- * @return mixed
+ * @return object
*/
function database($db = '', $return = FALSE, $active_record = FALSE)
{
@@ -125,6 +125,29 @@ class CI_Loader {
}
}
// END database()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Database Utilities Loader
+ *
+ * @access public
+ * @param string the DB platform
+ * @param bool whether to return the DB object
+ * @return object
+ */
+ function dbutils($db = '', $return = FALSE)
+ {
+ $obj =& get_instance();
+
+ if ( ! is_bool($return))
+ {
+ $return = FALSE;
+ }
+
+ return $obj->_ci_init_dbutils($db, $return);
+ }
+ // END dbutils()
// --------------------------------------------------------------------