diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index aaeee7f..7c42123 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -181,8 +181,17 @@
return DB($params, $active_record);
}
+ // Grab the super object
$CI =& get_instance();
- $CI->db =& DB($params, $active_record);
+
+ // Initialize the db variable. Needed to prevent
+ // reference errors with some configurations
+ $CI->db = '';
+
+ // Load the DB class
+ $CI->db =& DB($params, $active_record);
+
+ // Assign the DB object to any existing models
$this->_ci_assign_to_models();
}
@@ -828,11 +837,6 @@
*/
function _ci_assign_to_models()
{
- if (count($this->_ci_models) == 0)
- {
- return;
- }
-
if ($this->_ci_is_instance())
{
$CI =& get_instance();