Fixed bug #1813 - added check for $CI->db isset() and is_object() before returning false in Loader::database()
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index a59d6e3..576cb11 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -193,8 +193,11 @@
 	 */	

 	function database($params = '', $return = FALSE, $active_record = FALSE)

 	{

+		// Grab the super object

+		$CI =& get_instance();

+		

 		// Do we even need to load the database class?

-		if (class_exists('CI_DB') AND $return == FALSE AND $active_record == FALSE)

+		if (class_exists('CI_DB') AND $return == FALSE AND $active_record == FALSE AND isset($CI->db) AND is_object($CI->db))

 		{

 			return FALSE;

 		}	

@@ -205,9 +208,6 @@
 		{

 			return DB($params, $active_record);

 		}

-

-		// Grab the super object

-		$CI =& get_instance();

 		

 		// Initialize the db variable.  Needed to prevent   

 		// reference errors with some configurations