DB count_all() not returns an integer always
Added some syntactical improvements within DB (braces)
Fixed a bug when doing 'random' on order_by() (#5706).
Fixed a bug where adding a primary key through Forge could fail (#5731).
Fixed a bug when using DB cache on multiple databases (#5737).
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index fde0a43..dac4c8b 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -613,7 +613,7 @@
 	 */	
 	function is_write_type($sql)
 	{
-		if ( ! preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql))
+		if ( ! preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql))
 		{
 			return FALSE;
 		}
@@ -1086,12 +1086,15 @@
 		{
 			return TRUE;
 		}
-	
-		if ( ! @include(BASEPATH.'database/DB_cache'.EXT))
+
+		if ( ! class_exists('CI_DB_Cache'))
 		{
-			return $this->cache_off();
+			if ( ! @include(BASEPATH.'database/DB_cache'.EXT))
+			{
+				return $this->cache_off();
+			}
 		}
-		
+
 		$this->CACHE = new CI_DB_Cache($this); // pass db object to support multiple db connections and returned db objects
 		return TRUE;
 	}
@@ -1196,7 +1199,19 @@
 		{
 			$protect_identifiers = $this->_protect_identifiers;
 		}
-		
+
+		if (is_array($item))
+		{
+			$escaped_array = array();
+
+			foreach($item as $k => $v)
+			{
+				$escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v);
+			}
+
+			return $escaped_array;
+		}
+
 		// Convert tabs or multiple spaces into single spaces
 		$item = preg_replace('/[\t| ]+/', ' ', $item);