Merge pull request #1262 from Korri/develop

Fix Issue #627
diff --git a/.travis.yml b/.travis.yml
index 84029b9..97ea042 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,14 +8,17 @@
   - DB=mysql
   - DB=pgsql
   - DB=sqlite
+  - DB=pdo/mysql
+  - DB=pdo/pgsql
+  - DB=pdo/sqlite
 
 before_script:
   - pyrus channel-discover pear.php-tools.net
   - pyrus install http://pear.php-tools.net/get/vfsStream-0.11.2.tgz
   - phpenv rehash
-  - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi"
-  - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi"
-  - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi"
+  - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi"
+  - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi"
+  - sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi"
 
 script: phpunit --configuration tests/travis/$DB.phpunit.xml
 
diff --git a/application/config/database.php b/application/config/database.php
index 8c06dd2..1949873 100644
--- a/application/config/database.php
+++ b/application/config/database.php
@@ -43,9 +43,10 @@
 |	['password'] The password used to connect to the database
 |	['database'] The name of the database you want to connect to
 |	['dbdriver'] The database type. e.g.: mysql.  Currently supported:
-				 mysql, mysqli, pdo, postgre, odbc, mssql, sqlite, oci8
+|				 cubrid, interbase, mssql, mysql, mysqli, oci8, 
+|				 odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
 |	['dbprefix'] You can add an optional prefix, which will be added
-|				 to the table name when using the  Active Record class
+|				 to the table name when using the  Query Builder class
 |	['pconnect'] TRUE/FALSE - Whether to use a persistent connection
 |	['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
 |	['cache_on'] TRUE/FALSE - Enables/disables query caching
@@ -68,12 +69,12 @@
 | The $active_group variable lets you choose which connection group to
 | make active.  By default there is only one group (the 'default' group).
 |
-| The $active_record variables lets you determine whether or not to load
-| the active record class
+| The $query_builder variables lets you determine whether or not to load
+| the query builder class
 */
 
 $active_group = 'default';
-$active_record = TRUE;
+$query_builder = TRUE;
 
 $db['default'] = array(
 	'dsn'	=> '',
diff --git a/application/config/foreign_chars.php b/application/config/foreign_chars.php
index e2d3f23..41de123 100644
--- a/application/config/foreign_chars.php
+++ b/application/config/foreign_chars.php
@@ -40,50 +40,55 @@
 	'/Ä/' => 'Ae',
 	'/Ü/' => 'Ue',
 	'/Ö/' => 'Oe',
-	'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ/' => 'A',
-	'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª/' => 'a',
+	'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Α|Ά/' => 'A',
+	'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|α|ά/' => 'a',
 	'/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
 	'/ç|ć|ĉ|ċ|č/' => 'c',
-	'/Ð|Ď|Đ/' => 'Dj',
-	'/ð|ď|đ/' => 'dj',
-	'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě/' => 'E',
-	'/è|é|ê|ë|ē|ĕ|ė|ę|ě/' => 'e',
-	'/Ĝ|Ğ|Ġ|Ģ/' => 'G',
-	'/ĝ|ğ|ġ|ģ/' => 'g',
+	'/Ð|Ď|Đ|Δ/' => 'Dj',
+	'/ð|ď|đ|δ/' => 'dj',
+	'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ε|Έ/' => 'E',
+	'/è|é|ê|ë|ē|ĕ|ė|ę|ě|έ|ε/' => 'e',
+	'/Ĝ|Ğ|Ġ|Ģ|Γ/' => 'G',
+	'/ĝ|ğ|ġ|ģ|γ/' => 'g',
 	'/Ĥ|Ħ/' => 'H',
 	'/ĥ|ħ/' => 'h',
-	'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ/' => 'I',
-	'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı/' => 'i',
+	'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Η|Ή|Ί|Ι|Ϊ/' => 'I',
+	'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|η|ή|ί|ι|ϊ/' => 'i',
 	'/Ĵ/' => 'J',
 	'/ĵ/' => 'j',
-	'/Ķ/' => 'K',
-	'/ķ/' => 'k',
-	'/Ĺ|Ļ|Ľ|Ŀ|Ł/' => 'L',
-	'/ĺ|ļ|ľ|ŀ|ł/' => 'l',
-	'/Ñ|Ń|Ņ|Ň/' => 'N',
-	'/ñ|ń|ņ|ň|ʼn/' => 'n',
-	'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ/' => 'O',
-	'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º/' => 'o',
-	'/Ŕ|Ŗ|Ř/' => 'R',
-	'/ŕ|ŗ|ř/' => 'r',
-	'/Ś|Ŝ|Ş|Š/' => 'S',
-	'/ś|ŝ|ş|š|ſ/' => 's',
-	'/Ţ|Ť|Ŧ/' => 'T',
-	'/ţ|ť|ŧ/' => 't',
+	'/Ķ|Κ/' => 'K',
+	'/ķ|κ/' => 'k',
+	'/Ĺ|Ļ|Ľ|Ŀ|Ł|Λ/' => 'L',
+	'/ĺ|ļ|ľ|ŀ|ł|λ/' => 'l',
+	'/Ñ|Ń|Ņ|Ň|Ν/' => 'N',
+	'/ñ|ń|ņ|ň|ʼn|ν/' => 'n',
+	'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ/' => 'O',
+	'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ/' => 'o',
+	'/Ŕ|Ŗ|Ř|Ρ/' => 'R',
+	'/ŕ|ŗ|ř|ρ/' => 'r',
+	'/Ś|Ŝ|Ş|Ș|Š|Σ/' => 'S',
+	'/ś|ŝ|ş|ș|š|ſ|σ|ς/' => 's',
+	'/Ț|Ţ|Ť|Ŧ|τ/' => 'T',
+	'/ț|ţ|ť|ŧ/' => 't',
 	'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ/' => 'U',
-	'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ/' => 'u',
-	'/Ý|Ÿ|Ŷ/' => 'Y',
+	'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ/' => 'u',
+	'/Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ/' => 'Y',
 	'/ý|ÿ|ŷ/' => 'y',
 	'/Ŵ/' => 'W',
 	'/ŵ/' => 'w',
-	'/Ź|Ż|Ž/' => 'Z',
-	'/ź|ż|ž/' => 'z',
+	'/Ź|Ż|Ž|Ζ/' => 'Z',
+	'/ź|ż|ž|ζ/' => 'z',
 	'/Æ|Ǽ/' => 'AE',
 	'/ß/'=> 'ss',
 	'/IJ/' => 'IJ',
 	'/ij/' => 'ij',
 	'/Œ/' => 'OE',
-	'/ƒ/' => 'f'
+	'/ƒ/' => 'f',
+	'/ξ/' => 'ks',
+	'/π/' => 'p',
+	'/β/' => 'v',
+	'/μ/' => 'm',
+	'/ψ/' => 'ps',
 );
 
 /* End of file foreign_chars.php */
diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php
index f6b634d..39027e8 100755
--- a/system/core/Benchmark.php
+++ b/system/core/Benchmark.php
@@ -61,7 +61,7 @@
 	 */
 	public function mark($name)
 	{
-		$this->marker[$name] = microtime();
+		$this->marker[$name] = microtime(TRUE);
 	}
 
 	// --------------------------------------------------------------------
@@ -93,13 +93,10 @@
 
 		if ( ! isset($this->marker[$point2]))
 		{
-			$this->marker[$point2] = microtime();
+			$this->marker[$point2] = microtime(TRUE);
 		}
 
-		list($sm, $ss) = explode(' ', $this->marker[$point1]);
-		list($em, $es) = explode(' ', $this->marker[$point2]);
-
-		return number_format(($em + $es) - ($sm + $ss), $decimals);
+		return number_format($this->marker[$point2] - $this->marker[$point1], $decimals);
 	}
 
 	// --------------------------------------------------------------------
@@ -122,4 +119,4 @@
 }
 
 /* End of file Benchmark.php */
-/* Location: ./system/core/Benchmark.php */
+/* Location: ./system/core/Benchmark.php */
\ No newline at end of file
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 4885f31..92187fa 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -275,12 +275,12 @@
 		{
 			$x = explode('/', $RTR->routes['404_override'], 2);
 			$class = $x[0];
-			$method = (isset($x[1]) ? $x[1] : 'index');
+			$method = isset($x[1]) ? $x[1] : 'index';
 			if ( ! class_exists($class))
 			{
 				if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
 				{
-					show_404("{$class}/{$method}");
+					show_404($class.'/'.$method);
 				}
 
 				include_once(APPPATH.'controllers/'.$class.'.php');
@@ -288,7 +288,7 @@
 		}
 		else
 		{
-			show_404("{$class}/{$method}");
+			show_404($class.'/'.$method);
 		}
 	}
 
@@ -337,12 +337,12 @@
 			{
 				$x = explode('/', $RTR->routes['404_override'], 2);
 				$class = $x[0];
-				$method = (isset($x[1]) ? $x[1] : 'index');
+				$method = isset($x[1]) ? $x[1] : 'index';
 				if ( ! class_exists($class))
 				{
 					if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
 					{
-						show_404("{$class}/{$method}");
+						show_404($class.'/'.$method);
 					}
 
 					include_once(APPPATH.'controllers/'.$class.'.php');
@@ -352,7 +352,7 @@
 			}
 			else
 			{
-				show_404("{$class}/{$method}");
+				show_404($class.'/'.$method);
 			}
 		}
 
@@ -393,10 +393,10 @@
  *  Close the DB connection if one exists
  * ------------------------------------------------------
  */
-	if (class_exists('CI_DB') && isset($CI->db))
+	if (class_exists('CI_DB') && isset($CI->db) && ! $CI->db->pconnect)
 	{
 		$CI->db->close();
 	}
 
 /* End of file CodeIgniter.php */
-/* Location: ./system/core/CodeIgniter.php */
+/* Location: ./system/core/CodeIgniter.php */
\ No newline at end of file
diff --git a/system/core/Loader.php b/system/core/Loader.php
index a4039c6..5f2137d 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -313,16 +313,16 @@
 	 *
 	 * @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)
+	 * @param	bool	whether to enable query builder (this allows us to override the config setting)
 	 * @return	object
 	 */
-	public function database($params = '', $return = FALSE, $active_record = NULL)
+	public function database($params = '', $return = FALSE, $query_builder = NULL)
 	{
 		// Grab the super object
 		$CI =& get_instance();
 
 		// Do we even need to load the database class?
-		if (class_exists('CI_DB') && $return == FALSE && $active_record == NULL && isset($CI->db) && is_object($CI->db))
+		if (class_exists('CI_DB') && $return == FALSE && $query_builder == NULL && isset($CI->db) && is_object($CI->db))
 		{
 			return FALSE;
 		}
@@ -331,7 +331,7 @@
 
 		if ($return === TRUE)
 		{
-			return DB($params, $active_record);
+			return DB($params, $query_builder);
 		}
 
 		// Initialize the db variable. Needed to prevent
@@ -339,7 +339,7 @@
 		$CI->db = '';
 
 		// Load the DB class
-		$CI->db =& DB($params, $active_record);
+		$CI->db =& DB($params, $query_builder);
 	}
 
 	// --------------------------------------------------------------------
@@ -1254,4 +1254,4 @@
 }
 
 /* End of file Loader.php */
-/* Location: ./system/core/Loader.php */
\ No newline at end of file
+/* Location: ./system/core/Loader.php */
diff --git a/system/core/Router.php b/system/core/Router.php
index 5477fed..fa88cb3 100755
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -237,9 +237,12 @@
 			$segments[1] = 'index';
 		}
 
+		// This is being routed to a file in a sub directory
+		$this->directory and array_unshift($segments, trim($this->directory, '/'));
+
 		// Update our "routed" segment array to contain the segments.
 		// Note: If there is no custom routing, this array will be
-		// identical to $this->uri->segments
+		// identical to $this->uri->segments		
 		$this->uri->rsegments = $segments;
 	}
 
diff --git a/system/core/URI.php b/system/core/URI.php
index 48bb7ae..17300df 100755
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -641,10 +641,10 @@
 	 */
 	public function ruri_string()
 	{
-		return '/'.implode('/', $this->rsegment_array());
+		return implode('/', $this->rsegment_array());
 	}
 
 }
 
 /* End of file URI.php */
-/* Location: ./system/core/URI.php */
+/* Location: ./system/core/URI.php */
\ No newline at end of file
diff --git a/system/database/DB.php b/system/database/DB.php
index 0d81e40..b28439b 100755
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -32,9 +32,9 @@
  * @author		EllisLab Dev Team
  * @link		http://codeigniter.com/user_guide/database/
  * @param 	string
- * @param 	bool	Determines if active record should be used or not
+ * @param 	bool	Determines if query builder should be used or not
  */
-function &DB($params = '', $active_record_override = NULL)
+function &DB($params = '', $query_builder_override = NULL)
 {
 	// Load the DB config file if a DSN string wasn't passed
 	if (is_string($params) && strpos($params, '://') === FALSE)
@@ -111,22 +111,22 @@
 		show_error('You have not selected a database type to connect to.');
 	}
 
-	// Load the DB classes. Note: Since the active record class is optional
+	// Load the DB classes. Note: Since the query builder class is optional
 	// we need to dynamically create a class that extends proper parent class
-	// based on whether we're using the active record class or not.
-	if ($active_record_override !== NULL)
+	// based on whether we're using the query builder class or not.
+	if ($query_builder_override !== NULL)
 	{
-		$active_record = $active_record_override;
+		$query_builder = $query_builder_override;
 	}
 
 	require_once(BASEPATH.'database/DB_driver.php');
 
-	if ( ! isset($active_record) OR $active_record == TRUE)
+	if ( ! isset($query_builder) OR $query_builder == TRUE)
 	{
-		require_once(BASEPATH.'database/DB_active_rec.php');
+		require_once(BASEPATH.'database/DB_query_builder.php');
 		if ( ! class_exists('CI_DB'))
 		{
-			class CI_DB extends CI_DB_active_record { }
+			class CI_DB extends CI_DB_query_builder { }
 		}
 	}
 	elseif ( ! class_exists('CI_DB'))
@@ -159,4 +159,4 @@
 }
 
 /* End of file DB.php */
-/* Location: ./system/database/DB.php */
\ No newline at end of file
+/* Location: ./system/database/DB.php */
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 61b05d5..ef77b59 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -335,7 +335,7 @@
 		}
 
 		// Start the Query Timer
-		$time_start = list($sm, $ss) = explode(' ', microtime());
+		$time_start = microtime(TRUE);
 
 		// Run the Query
 		if (FALSE === ($this->result_id = $this->simple_query($sql)))
@@ -370,12 +370,12 @@
 		}
 
 		// Stop and aggregate the query time results
-		$time_end = list($em, $es) = explode(' ', microtime());
-		$this->benchmark += ($em + $es) - ($sm + $ss);
+		$time_end = microtime(TRUE);
+		$this->benchmark += $time_end - $time_start;
 
 		if ($this->save_queries == TRUE)
 		{
-			$this->query_times[] = ($em + $es) - ($sm + $ss);
+			$this->query_times[] = $time_end - $time_start;
 		}
 
 		// Increment the query counter
@@ -1208,7 +1208,7 @@
 	/**
 	 * Protect Identifiers
 	 *
-	 * This function is used extensively by the Active Record class, and by
+	 * This function is used extensively by the Query Builder class, and by
 	 * a couple functions in this class.
 	 * It takes a column or table name (optionally with an alias) and inserts
 	 * the table prefix onto it. Some logic is necessary in order to deal with
@@ -1283,7 +1283,7 @@
 			// Does the first segment of the exploded item match
 			// one of the aliases previously identified? If so,
 			// we have nothing more to do other than escape the item
-			if (in_array($parts[0], $this->ar_aliased_tables))
+			if (in_array($parts[0], $this->qb_aliased_tables))
 			{
 				if ($protect_identifiers === TRUE)
 				{
@@ -1380,7 +1380,7 @@
 	// --------------------------------------------------------------------
 
 	/**
-	 * Dummy method that allows Active Record class to be disabled
+	 * Dummy method that allows Query Builder class to be disabled
 	 *
 	 * This function is used extensively by every db driver.
 	 *
@@ -1393,4 +1393,4 @@
 }
 
 /* End of file DB_driver.php */
-/* Location: ./system/database/DB_driver.php */
\ No newline at end of file
+/* Location: ./system/database/DB_driver.php */
diff --git a/system/database/DB_active_rec.php b/system/database/DB_query_builder.php
similarity index 79%
rename from system/database/DB_active_rec.php
rename to system/database/DB_query_builder.php
index a5df7f3..393a1cd 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_query_builder.php
@@ -26,9 +26,9 @@
  */
 
 /**
- * Active Record Class
+ * Query Builder Class
  *
- * This is the platform-independent base Active Record implementation class.
+ * This is the platform-independent base Query Builder implementation class.
  *
  * @package		CodeIgniter
  * @subpackage	Drivers
@@ -36,46 +36,47 @@
  * @author		EllisLab Dev Team
  * @link		http://codeigniter.com/user_guide/database/
  */
-abstract class CI_DB_active_record extends CI_DB_driver {
+
+abstract class CI_DB_query_builder extends CI_DB_driver {
 
 	protected $return_delete_sql		= FALSE;
 	protected $reset_delete_data		= FALSE;
 
-	protected $ar_select			= array();
-	protected $ar_distinct			= FALSE;
-	protected $ar_from			= array();
-	protected $ar_join			= array();
-	protected $ar_where			= array();
-	protected $ar_like			= array();
-	protected $ar_groupby			= array();
-	protected $ar_having			= array();
-	protected $ar_keys			= array();
-	protected $ar_limit			= FALSE;
-	protected $ar_offset			= FALSE;
-	protected $ar_order			= FALSE;
-	protected $ar_orderby			= array();
-	protected $ar_set			= array();
-	protected $ar_wherein			= array();
-	protected $ar_aliased_tables		= array();
-	protected $ar_store_array		= array();
-	protected $ar_where_group_started	= FALSE;
-	protected $ar_where_group_count		= 0;
+	protected $qb_select			= array();
+	protected $qb_distinct			= FALSE;
+	protected $qb_from			= array();
+	protected $qb_join			= array();
+	protected $qb_where			= array();
+	protected $qb_like			= array();
+	protected $qb_groupby			= array();
+	protected $qb_having			= array();
+	protected $qb_keys			= array();
+	protected $qb_limit			= FALSE;
+	protected $qb_offset			= FALSE;
+	protected $qb_order			= FALSE;
+	protected $qb_orderby			= array();
+	protected $qb_set			= array();
+	protected $qb_wherein			= array();
+	protected $qb_aliased_tables		= array();
+	protected $qb_store_array		= array();
+	protected $qb_where_group_started	= FALSE;
+	protected $qb_where_group_count		= 0;
 
-	// Active Record Caching variables
-	protected $ar_caching				= FALSE;
-	protected $ar_cache_exists			= array();
-	protected $ar_cache_select			= array();
-	protected $ar_cache_from			= array();
-	protected $ar_cache_join			= array();
-	protected $ar_cache_where			= array();
-	protected $ar_cache_like			= array();
-	protected $ar_cache_groupby			= array();
-	protected $ar_cache_having			= array();
-	protected $ar_cache_orderby			= array();
-	protected $ar_cache_set				= array();
+	// Query Builder Caching variables
+	protected $qb_caching				= FALSE;
+	protected $qb_cache_exists			= array();
+	protected $qb_cache_select			= array();
+	protected $qb_cache_from			= array();
+	protected $qb_cache_join			= array();
+	protected $qb_cache_where			= array();
+	protected $qb_cache_like			= array();
+	protected $qb_cache_groupby			= array();
+	protected $qb_cache_having			= array();
+	protected $qb_cache_orderby			= array();
+	protected $qb_cache_set				= array();
 
-	protected $ar_no_escape 			= array();
-	protected $ar_cache_no_escape			= array();
+	protected $qb_no_escape 			= array();
+	protected $qb_cache_no_escape			= array();
 
 	/**
 	 * Select
@@ -98,14 +99,14 @@
 
 			if ($val != '')
 			{
-				$this->ar_select[] = $val;
-				$this->ar_no_escape[] = $escape;
+				$this->qb_select[] = $val;
+				$this->qb_no_escape[] = $escape;
 
-				if ($this->ar_caching === TRUE)
+				if ($this->qb_caching === TRUE)
 				{
-					$this->ar_cache_select[] = $val;
-					$this->ar_cache_exists[] = 'select';
-					$this->ar_cache_no_escape[] = $escape;
+					$this->qb_cache_select[] = $val;
+					$this->qb_cache_exists[] = 'select';
+					$this->qb_cache_no_escape[] = $escape;
 				}
 			}
 		}
@@ -211,13 +212,14 @@
 		}
 
 		$sql = $this->protect_identifiers($type.'('.trim($select).')').' AS '.$this->protect_identifiers(trim($alias));
-		$this->ar_select[] = $sql;
-		$this->ar_no_escape[] = NULL;
+		
+		$this->qb_select[] = $sql;
+		$this->qb_no_escape[] = NULL;
 
-		if ($this->ar_caching === TRUE)
+		if ($this->qb_caching === TRUE)
 		{
-			$this->ar_cache_select[] = $sql;
-			$this->ar_cache_exists[] = 'select';
+			$this->qb_cache_select[] = $sql;
+			$this->qb_cache_exists[] = 'select';
 		}
 
 		return $this;
@@ -254,7 +256,7 @@
 	 */
 	public function distinct($val = TRUE)
 	{
-		$this->ar_distinct = (is_bool($val)) ? $val : TRUE;
+		$this->qb_distinct = (is_bool($val)) ? $val : TRUE;
 		return $this;
 	}
 
@@ -278,12 +280,13 @@
 				{
 					$v = trim($v);
 					$this->_track_aliases($v);
-					$v = $this->ar_from[] = $this->protect_identifiers($v, TRUE, NULL, FALSE);
 
-					if ($this->ar_caching === TRUE)
+					$v = $this->qb_from[] = $this->protect_identifiers($v, TRUE, NULL, FALSE);
+
+					if ($this->qb_caching === TRUE)
 					{
-						$this->ar_cache_from[] = $v;
-						$this->ar_cache_exists[] = 'from';
+						$this->qb_cache_from[] = $v;
+						$this->qb_cache_exists[] = 'from';
 					}
 				}
 			}
@@ -292,14 +295,15 @@
 				$val = trim($val);
 
 				// Extract any aliases that might exist. We use this information
-				// in the _protect_identifiers to know whether to add a table prefix
+				// in the protect_identifiers to know whether to add a table prefix
 				$this->_track_aliases($val);
-				$this->ar_from[] = $val = $this->protect_identifiers($val, TRUE, NULL, FALSE);
 
-				if ($this->ar_caching === TRUE)
+				$this->qb_from[] = $val = $this->protect_identifiers($val, TRUE, NULL, FALSE);
+
+				if ($this->qb_caching === TRUE)
 				{
-					$this->ar_cache_from[] = $val;
-					$this->ar_cache_exists[] = 'from';
+					$this->qb_cache_from[] = $val;
+					$this->qb_cache_exists[] = 'from';
 				}
 			}
 		}
@@ -336,7 +340,7 @@
 		}
 
 		// Extract any aliases that might exist. We use this information
-		// in the _protect_identifiers to know whether to add a table prefix
+		// in the protect_identifiers to know whether to add a table prefix
 		$this->_track_aliases($table);
 
 		// Strip apart the condition and protect the identifiers
@@ -346,12 +350,12 @@
 		}
 
 		// Assemble the JOIN statement
-		$this->ar_join[] = $join = $type.'JOIN '.$this->protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond;
+		$this->qb_join[] = $join = $type.'JOIN '.$this->protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond;
 
-		if ($this->ar_caching === TRUE)
+		if ($this->qb_caching === TRUE)
 		{
-			$this->ar_cache_join[] = $join;
-			$this->ar_cache_exists[] = 'join';
+			$this->qb_cache_join[] = $join;
+			$this->qb_cache_exists[] = 'join';
 		}
 
 		return $this;
@@ -420,7 +424,7 @@
 
 		foreach ($key as $k => $v)
 		{
-			$prefix = (count($this->ar_where) === 0 && count($this->ar_cache_where) === 0) ? '' : $type;
+			$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
 
 			if (is_null($v) && ! $this->_has_operator($k))
 			{
@@ -446,11 +450,11 @@
 				$k = $this->protect_identifiers($k, FALSE, $escape);
 			}
 
-			$this->ar_where[] = $prefix.$k.$v;
-			if ($this->ar_caching === TRUE)
+			$this->qb_where[] = $prefix.$k.$v;
+			if ($this->qb_caching === TRUE)
 			{
-				$this->ar_cache_where[] = $prefix.$k.$v;
-				$this->ar_cache_exists[] = 'where';
+				$this->qb_cache_where[] = $prefix.$k.$v;
+				$this->qb_cache_exists[] = 'where';
 			}
 
 		}
@@ -557,20 +561,20 @@
 
 		foreach ($values as $value)
 		{
-			$this->ar_wherein[] = $this->escape($value);
+			$this->qb_wherein[] = $this->escape($value);
 		}
 
-		$prefix = (count($this->ar_where) === 0) ? '' : $type;
-		$this->ar_where[] = $where_in = $prefix.$this->protect_identifiers($key).$not.' IN ('.implode(', ', $this->ar_wherein).') ';
+		$prefix = (count($this->qb_where) === 0) ? '' : $type;
+		$this->qb_where[] = $where_in = $prefix.$this->protect_identifiers($key).$not.' IN ('.implode(', ', $this->qb_wherein).') ';
 
-		if ($this->ar_caching === TRUE)
+		if ($this->qb_caching === TRUE)
 		{
-			$this->ar_cache_where[] = $where_in;
-			$this->ar_cache_exists[] = 'where';
+			$this->qb_cache_where[] = $where_in;
+			$this->qb_cache_exists[] = 'where';
 		}
 
 		// reset the array for multiple calls
-		$this->ar_wherein = array();
+		$this->qb_wherein = array();
 		return $this;
 	}
 
@@ -666,7 +670,7 @@
 		foreach ($field as $k => $v)
 		{
 			$k = $this->protect_identifiers($k);
-			$prefix = (count($this->ar_like) === 0) ? '' : $type;
+			$prefix = (count($this->qb_like) === 0) ? '' : $type;
 			$v = $this->escape_like_str($v);
 
 			if ($side === 'none')
@@ -692,11 +696,11 @@
 				$like_statement = $like_statement.sprintf($this->_like_escape_str, $this->_like_escape_chr);
 			}
 
-			$this->ar_like[] = $like_statement;
-			if ($this->ar_caching === TRUE)
+			$this->qb_like[] = $like_statement;
+			if ($this->qb_caching === TRUE)
 			{
-				$this->ar_cache_like[] = $like_statement;
-				$this->ar_cache_exists[] = 'like';
+				$this->qb_cache_like[] = $like_statement;
+				$this->qb_cache_exists[] = 'like';
 			}
 
 		}
@@ -716,13 +720,14 @@
 	public function group_start($not = '', $type = 'AND ')
 	{
 		$type = $this->_group_get_type($type);
-		$this->ar_where_group_started = TRUE;
-		$prefix = (count($this->ar_where) === 0 && count($this->ar_cache_where) === 0) ? '' : $type;
-		$this->ar_where[] = $value = $prefix.$not.str_repeat(' ', ++$this->ar_where_group_count).' (';
 
-		if ($this->ar_caching)
+		$this->qb_where_group_started = TRUE;
+		$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
+		$this->qb_where[] = $value = $prefix.$not.str_repeat(' ', ++$this->qb_where_group_count).' (';
+
+		if ($this->qb_caching)
 		{
-			$this->ar_cache_where[] = $value;
+			$this->qb_cache_where[] = $value;
 		}
 
 		return $this;
@@ -773,12 +778,12 @@
 	 */
 	public function group_end()
 	{
-		$this->ar_where_group_started = FALSE;
-		$this->ar_where[] = $value = str_repeat(' ', $this->ar_where_group_count--) . ')';
+		$this->qb_where_group_started = FALSE;
+		$this->qb_where[] = $value = str_repeat(' ', $this->qb_where_group_count--) . ')';
 
-		if ($this->ar_caching)
+		if ($this->qb_caching)
 		{
-			$this->ar_cache_where[] = $value;
+			$this->qb_cache_where[] = $value;
 		}
 
 		return $this;
@@ -796,10 +801,10 @@
 	 */
 	protected function _group_get_type($type)
 	{
-		if ($this->ar_where_group_started)
+		if ($this->qb_where_group_started)
 		{
 			$type = '';
-			$this->ar_where_group_started = FALSE;
+			$this->qb_where_group_started = FALSE;
 		}
 
 		return $type;
@@ -826,12 +831,12 @@
 
 			if ($val != '')
 			{
-				$this->ar_groupby[] = $val = $this->protect_identifiers($val);
+				$this->qb_groupby[] = $val = $this->protect_identifiers($val);
 
-				if ($this->ar_caching === TRUE)
+				if ($this->qb_caching === TRUE)
 				{
-					$this->ar_cache_groupby[] = $val;
-					$this->ar_cache_exists[] = 'groupby';
+					$this->qb_cache_groupby[] = $val;
+					$this->qb_cache_exists[] = 'groupby';
 				}
 			}
 		}
@@ -891,7 +896,7 @@
 
 		foreach ($key as $k => $v)
 		{
-			$prefix = (count($this->ar_having) === 0) ? '' : $type;
+			$prefix = (count($this->qb_having) === 0) ? '' : $type;
 
 			if ($escape === TRUE)
 			{
@@ -908,11 +913,11 @@
 				$v = ' '.$this->escape($v);
 			}
 
-			$this->ar_having[] = $prefix.$k.$v;
-			if ($this->ar_caching === TRUE)
+			$this->qb_having[] = $prefix.$k.$v;
+			if ($this->qb_caching === TRUE)
 			{
-				$this->ar_cache_having[] = $prefix.$k.$v;
-				$this->ar_cache_exists[] = 'having';
+				$this->qb_cache_having[] = $prefix.$k.$v;
+				$this->qb_cache_exists[] = 'having';
 			}
 		}
 
@@ -948,7 +953,7 @@
 			foreach (explode(',', $orderby) as $part)
 			{
 				$part = trim($part);
-				if ( ! in_array($part, $this->ar_aliased_tables))
+				if ( ! in_array($part, $this->qb_aliased_tables))
 				{
 					$part = $this->protect_identifiers(trim($part));
 				}
@@ -966,12 +971,12 @@
 			}
 		}
 
-		$this->ar_orderby[] = $orderby_statement = $orderby.$direction;
+		$this->qb_orderby[] = $orderby_statement = $orderby.$direction;
 
-		if ($this->ar_caching === TRUE)
+		if ($this->qb_caching === TRUE)
 		{
-			$this->ar_cache_orderby[] = $orderby_statement;
-			$this->ar_cache_exists[] = 'orderby';
+			$this->qb_cache_orderby[] = $orderby_statement;
+			$this->qb_cache_exists[] = 'orderby';
 		}
 
 		return $this;
@@ -988,11 +993,11 @@
 	 */
 	public function limit($value, $offset = NULL)
 	{
-		$this->ar_limit = (int) $value;
+		$this->qb_limit = (int) $value;
 
 		if ( ! is_null($offset))
 		{
-			$this->ar_offset = (int) $offset;
+			$this->qb_offset = (int) $offset;
 		}
 
 		return $this;
@@ -1008,7 +1013,7 @@
 	 */
 	public function offset($offset)
 	{
-		$this->ar_offset = (int) $offset;
+		$this->qb_offset = (int) $offset;
 		return $this;
 	}
 
@@ -1035,11 +1040,11 @@
 		{
 			if ($escape === FALSE)
 			{
-				$this->ar_set[$this->protect_identifiers($k)] = $v;
+				$this->qb_set[$this->protect_identifiers($k)] = $v;
 			}
 			else
 			{
-				$this->ar_set[$this->protect_identifiers($k, FALSE, TRUE)] = $this->escape($v);
+				$this->qb_set[$this->protect_identifiers($k, FALSE, TRUE)] = $this->escape($v);
 			}
 		}
 
@@ -1054,7 +1059,7 @@
 	 * Compiles a SELECT query string and returns the sql.
 	 *
 	 * @param	string	the table name to select from (optional)
-	 * @param	bool	TRUE: resets AR values; FALSE: leave AR vaules alone
+	 * @param	bool	TRUE: resets QB values; FALSE: leave QB vaules alone
 	 * @return	string
 	 */
 	public function get_compiled_select($table = '', $reset = TRUE)
@@ -1110,7 +1115,7 @@
 	 * "Count All Results" query
 	 *
 	 * Generates a platform-specific query string that counts all records
-	 * returned by an Active Record query.
+	 * returned by an Query Builder query.
 	 *
 	 * @param	string
 	 * @return	string
@@ -1186,7 +1191,7 @@
 			$this->set_insert_batch($set);
 		}
 
-		if (count($this->ar_set) === 0)
+		if (count($this->qb_set) === 0)
 		{
 			if ($this->db_debug)
 			{
@@ -1198,18 +1203,18 @@
 
 		if ($table == '')
 		{
-			if ( ! isset($this->ar_from[0]))
+			if ( ! isset($this->qb_from[0]))
 			{
 				return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE;
 			}
 
-			$table = $this->ar_from[0];
+			$table = $this->qb_from[0];
 		}
 
 		// Batch this baby
-		for ($i = 0, $total = count($this->ar_set); $i < $total; $i += 100)
+		for ($i = 0, $total = count($this->qb_set); $i < $total; $i += 100)
 		{
-			$this->query($this->_insert_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_keys, array_slice($this->ar_set, $i, 100)));
+			$this->query($this->_insert_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), $this->qb_keys, array_slice($this->qb_set, $i, 100)));
 		}
 
 		$this->_reset_write();
@@ -1252,15 +1257,16 @@
 			$key = array($key => $value);
 		}
 
-		$keys = array_keys(current($key));
+		$keys = array_keys($this->_object_to_array(current($key)));
 		sort($keys);
 
 		foreach ($key as $row)
 		{
+			$row = $this->_object_to_array($row);
 			if (count(array_diff($keys, array_keys($row))) > 0 OR count(array_diff(array_keys($row), $keys)) > 0)
 			{
 				// batch function above returns an error on an empty array
-				$this->ar_set[] = array();
+				$this->qb_set[] = array();
 				return;
 			}
 
@@ -1268,7 +1274,7 @@
 
 			if ($escape === FALSE)
 			{
-				$this->ar_set[] =  '('.implode(',', $row).')';
+				$this->qb_set[] =  '('.implode(',', $row).')';
 			}
 			else
 			{
@@ -1278,13 +1284,13 @@
 					$clean[] = $this->escape($value);
 				}
 
-				$this->ar_set[] =  '('.implode(',', $clean).')';
+				$this->qb_set[] =  '('.implode(',', $clean).')';
 			}
 		}
 
 		foreach ($keys as $k)
 		{
-			$this->ar_keys[] = $this->protect_identifiers($k);
+			$this->qb_keys[] = $this->protect_identifiers($k);
 		}
 
 		return $this;
@@ -1298,7 +1304,7 @@
 	 * Compiles an insert query and returns the sql
 	 *
 	 * @param	string	the table to insert into
-	 * @param	bool	TRUE: reset AR values; FALSE: leave AR values alone
+	 * @param	bool	TRUE: reset QB values; FALSE: leave QB values alone
 	 * @return	string
 	 */
 	public function get_compiled_insert($table = '', $reset = TRUE)
@@ -1309,9 +1315,11 @@
 		}
 
 		$sql = $this->_insert(
-			$this->protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE),
-			array_keys($this->ar_set),
-			array_values($this->ar_set)
+			$this->protect_identifiers(
+				$this->qb_from[0], TRUE, NULL, FALSE
+			),
+			array_keys($this->qb_set),
+			array_values($this->qb_set)
 		);
 
 		if ($reset === TRUE)
@@ -1346,9 +1354,11 @@
 		}
 
 		$sql = $this->_insert(
-			$this->protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE),
-			array_keys($this->ar_set),
-			array_values($this->ar_set)
+			$this->protect_identifiers(
+				$this->qb_from[0], TRUE, NULL, FALSE
+			),
+			array_keys($this->qb_set),
+			array_values($this->qb_set)
 		);
 
 		$this->_reset_write();
@@ -1386,21 +1396,21 @@
 	 */
 	protected function _validate_insert($table = '')
 	{
-		if (count($this->ar_set) === 0)
+		if (count($this->qb_set) === 0)
 		{
 			return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
 		}
 
 		if ($table == '')
 		{
-			if ( ! isset($this->ar_from[0]))
+			if ( ! isset($this->qb_from[0]))
 			{
 				return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE;
 			}
 		}
 		else
 		{
-			$this->ar_from[0] = $table;
+			$this->qb_from[0] = $table;
 		}
 
 		return TRUE;
@@ -1424,22 +1434,23 @@
 			$this->set($set);
 		}
 
-		if (count($this->ar_set) === 0)
+		if (count($this->qb_set) === 0)
 		{
 			return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
 		}
 
 		if ($table == '')
 		{
-			if ( ! isset($this->ar_from[0]))
+			if ( ! isset($this->qb_from[0]))
 			{
 				return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE;
 			}
 
-			$table = $this->ar_from[0];
+			$table = $this->qb_from[0];
 		}
 
-		$sql = $this->_replace($this->protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set));
+		$sql = $this->_replace($this->protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->qb_set), array_values($this->qb_set));
+
 		$this->_reset_write();
 		return $this->query($sql);
 	}
@@ -1469,7 +1480,7 @@
 	 * Compiles an update query and returns the sql
 	 *
 	 * @param	string	the table to update
-	 * @param	bool	TRUE: reset AR values; FALSE: leave AR values alone
+	 * @param	bool	TRUE: reset QB values; FALSE: leave QB values alone
 	 * @return	string
 	 */
 	public function get_compiled_update($table = '', $reset = TRUE)
@@ -1482,7 +1493,7 @@
 			return FALSE;
 		}
 
-		$sql = $this->_update($this->protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);
+		$sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set, $this->qb_where, $this->qb_orderby, $this->qb_limit);
 
 		if ($reset === TRUE)
 		{
@@ -1529,7 +1540,8 @@
 			$this->limit($limit);
 		}
 
-		$sql = $this->_update($this->protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit, $this->ar_like);
+		$sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set, $this->qb_where, $this->qb_orderby, $this->qb_limit, $this->qb_like);
+
 		$this->_reset_write();
 		return $this->query($sql);
 	}
@@ -1583,21 +1595,21 @@
 	 */
 	protected function _validate_update($table = '')
 	{
-		if (count($this->ar_set) == 0)
+		if (count($this->qb_set) == 0)
 		{
 			return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
 		}
 
 		if ($table == '')
 		{
-			if ( ! isset($this->ar_from[0]))
+			if ( ! isset($this->qb_from[0]))
 			{
 				return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE;
 			}
 		}
 		else
 		{
-			$this->ar_from[0] = $table;
+			$this->qb_from[0] = $table;
 		}
 
 		return TRUE;
@@ -1630,25 +1642,25 @@
 			$this->set_update_batch($set, $index);
 		}
 
-		if (count($this->ar_set) === 0)
+		if (count($this->qb_set) === 0)
 		{
 			return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
 		}
 
 		if ($table == '')
 		{
-			if ( ! isset($this->ar_from[0]))
+			if ( ! isset($this->qb_from[0]))
 			{
 				return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE;
 			}
 
-			$table = $this->ar_from[0];
+			$table = $this->qb_from[0];
 		}
 
 		// Batch this baby
-		for ($i = 0, $total = count($this->ar_set); $i < $total; $i += 100)
+		for ($i = 0, $total = count($this->qb_set); $i < $total; $i += 100)
 		{
-			$this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->ar_set, $i, 100), $this->protect_identifiers($index), $this->ar_where));
+			$this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, 100), $this->protect_identifiers($index), $this->qb_where));
 		}
 
 		$this->_reset_write();
@@ -1697,7 +1709,7 @@
 				return $this->display_error('db_batch_missing_index');
 			}
 
-			$this->ar_set[] = $clean;
+			$this->qb_set[] = $clean;
 		}
 
 		return $this;
@@ -1717,12 +1729,12 @@
 	{
 		if ($table == '')
 		{
-			if ( ! isset($this->ar_from[0]))
+			if ( ! isset($this->qb_from[0]))
 			{
 				return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE;
 			}
 
-			$table = $this->ar_from[0];
+			$table = $this->qb_from[0];
 		}
 		else
 		{
@@ -1750,12 +1762,12 @@
 	{
 		if ($table == '')
 		{
-			if ( ! isset($this->ar_from[0]))
+			if ( ! isset($this->qb_from[0]))
 			{
 				return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE;
 			}
 
-			$table = $this->ar_from[0];
+			$table = $this->qb_from[0];
 		}
 		else
 		{
@@ -1793,7 +1805,7 @@
 	 * Compiles a delete query string and returns the sql
 	 *
 	 * @param	string	the table to delete from
-	 * @param	bool	TRUE: reset AR values; FALSE: leave AR values alone
+	 * @param	bool	TRUE: reset QB values; FALSE: leave QB values alone
 	 * @return	string
 	 */
 	public function get_compiled_delete($table = '', $reset = TRUE)
@@ -1824,12 +1836,12 @@
 
 		if ($table == '')
 		{
-			if ( ! isset($this->ar_from[0]))
+			if ( ! isset($this->qb_from[0]))
 			{
 				return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE;
 			}
 
-			$table = $this->ar_from[0];
+			$table = $this->qb_from[0];
 		}
 		elseif (is_array($table))
 		{
@@ -1856,12 +1868,12 @@
 			$this->limit($limit);
 		}
 
-		if (count($this->ar_where) === 0 && count($this->ar_wherein) === 0 && count($this->ar_like) === 0)
+		if (count($this->qb_where) === 0 && count($this->qb_wherein) === 0 && count($this->qb_like) === 0)
 		{
 			return ($this->db_debug) ? $this->display_error('db_del_must_use_where') : FALSE;
 		}
 
-		$sql = $this->_delete($table, $this->ar_where, $this->ar_like, $this->ar_limit);
+		$sql = $this->_delete($table, $this->qb_where, $this->qb_like, $this->qb_limit);
 		if ($reset_data)
 		{
 			$this->_reset_write();
@@ -1968,9 +1980,9 @@
 			$table = trim(strrchr($table, ' '));
 
 			// Store the alias, if it doesn't already exist
-			if ( ! in_array($table, $this->ar_aliased_tables))
+			if ( ! in_array($table, $this->qb_aliased_tables))
 			{
-				$this->ar_aliased_tables[] = $table;
+				$this->qb_aliased_tables[] = $table;
 			}
 		}
 	}
@@ -1997,9 +2009,9 @@
 		}
 		else
 		{
-			$sql = ( ! $this->ar_distinct) ? 'SELECT ' : 'SELECT DISTINCT ';
+			$sql = ( ! $this->qb_distinct) ? 'SELECT ' : 'SELECT DISTINCT ';
 
-			if (count($this->ar_select) === 0)
+			if (count($this->qb_select) === 0)
 			{
 				$sql .= '*';
 			}
@@ -2008,73 +2020,73 @@
 				// Cycle through the "select" portion of the query and prep each column name.
 				// The reason we protect identifiers here rather then in the select() function
 				// is because until the user calls the from() function we don't know if there are aliases
-				foreach ($this->ar_select as $key => $val)
+				foreach ($this->qb_select as $key => $val)
 				{
-					$no_escape = isset($this->ar_no_escape[$key]) ? $this->ar_no_escape[$key] : NULL;
-					$this->ar_select[$key] = $this->protect_identifiers($val, FALSE, $no_escape);
+					$no_escape = isset($this->qb_no_escape[$key]) ? $this->qb_no_escape[$key] : NULL;
+					$this->qb_select[$key] = $this->protect_identifiers($val, FALSE, $no_escape);
 				}
 
-				$sql .= implode(', ', $this->ar_select);
+				$sql .= implode(', ', $this->qb_select);
 			}
 		}
 
 		// Write the "FROM" portion of the query
-		if (count($this->ar_from) > 0)
+		if (count($this->qb_from) > 0)
 		{
-			$sql .= "\nFROM ".$this->_from_tables($this->ar_from);
+			$sql .= "\nFROM ".$this->_from_tables($this->qb_from);
 		}
 
 		// Write the "JOIN" portion of the query
-		if (count($this->ar_join) > 0)
+		if (count($this->qb_join) > 0)
 		{
-			$sql .= "\n".implode("\n", $this->ar_join);
+			$sql .= "\n".implode("\n", $this->qb_join);
 		}
 
 		// Write the "WHERE" portion of the query
-		if (count($this->ar_where) > 0 OR count($this->ar_like) > 0)
+		if (count($this->qb_where) > 0 OR count($this->qb_like) > 0)
 		{
 			$sql .= "\nWHERE ";
 		}
 
-		$sql .= implode("\n", $this->ar_where);
+		$sql .= implode("\n", $this->qb_where);
 
 		// Write the "LIKE" portion of the query
-		if (count($this->ar_like) > 0)
+		if (count($this->qb_like) > 0)
 		{
-			if (count($this->ar_where) > 0)
+			if (count($this->qb_where) > 0)
 			{
 				$sql .= "\nAND ";
 			}
 
-			$sql .= implode("\n", $this->ar_like);
+			$sql .= implode("\n", $this->qb_like);
 		}
 
 		// Write the "GROUP BY" portion of the query
-		if (count($this->ar_groupby) > 0)
+		if (count($this->qb_groupby) > 0)
 		{
-			$sql .= "\nGROUP BY ".implode(', ', $this->ar_groupby);
+			$sql .= "\nGROUP BY ".implode(', ', $this->qb_groupby);
 		}
 
 		// Write the "HAVING" portion of the query
-		if (count($this->ar_having) > 0)
+		if (count($this->qb_having) > 0)
 		{
-			$sql .= "\nHAVING ".implode("\n", $this->ar_having);
+			$sql .= "\nHAVING ".implode("\n", $this->qb_having);
 		}
 
 		// Write the "ORDER BY" portion of the query
-		if (count($this->ar_orderby) > 0)
+		if (count($this->qb_orderby) > 0)
 		{
-			$sql .= "\nORDER BY ".implode(', ', $this->ar_orderby);
-			if ($this->ar_order !== FALSE)
+			$sql .= "\nORDER BY ".implode(', ', $this->qb_orderby);
+			if ($this->qb_order !== FALSE)
 			{
-				$sql .= ($this->ar_order == 'desc') ? ' DESC' : ' ASC';
+				$sql .= ($this->qb_order == 'desc') ? ' DESC' : ' ASC';
 			}
 		}
 
 		// Write the "LIMIT" portion of the query
-		if (is_numeric($this->ar_limit))
+		if (is_numeric($this->qb_limit))
 		{
-			return $this->_limit($sql."\n", $this->ar_limit, $this->ar_offset);
+			return $this->_limit($sql."\n", $this->qb_limit, $this->qb_offset);
 		}
 
 		return $sql;
@@ -2152,13 +2164,13 @@
 	/**
 	 * Start Cache
 	 *
-	 * Starts AR caching
+	 * Starts QB caching
 	 *
 	 * @return	void
 	 */
 	public function start_cache()
 	{
-		$this->ar_caching = TRUE;
+		$this->qb_caching = TRUE;
 	}
 
 	// --------------------------------------------------------------------
@@ -2166,13 +2178,13 @@
 	/**
 	 * Stop Cache
 	 *
-	 * Stops AR caching
+	 * Stops QB caching
 	 *
 	 * @return	void
 	 */
 	public function stop_cache()
 	{
-		$this->ar_caching = FALSE;
+		$this->qb_caching = FALSE;
 	}
 
 	// --------------------------------------------------------------------
@@ -2180,24 +2192,24 @@
 	/**
 	 * Flush Cache
 	 *
-	 * Empties the AR cache
+	 * Empties the QB cache
 	 *
 	 * @return	void
 	 */
 	public function flush_cache()
 	{
 		$this->_reset_run(array(
-			'ar_cache_select'		=> array(),
-			'ar_cache_from'			=> array(),
-			'ar_cache_join'			=> array(),
-			'ar_cache_where'		=> array(),
-			'ar_cache_like'			=> array(),
-			'ar_cache_groupby'		=> array(),
-			'ar_cache_having'		=> array(),
-			'ar_cache_orderby'		=> array(),
-			'ar_cache_set'			=> array(),
-			'ar_cache_exists'		=> array(),
-			'ar_cache_no_escape'	=> array()
+			'qb_cache_select'		=> array(),
+			'qb_cache_from'			=> array(),
+			'qb_cache_join'			=> array(),
+			'qb_cache_where'		=> array(),
+			'qb_cache_like'			=> array(),
+			'qb_cache_groupby'		=> array(),
+			'qb_cache_having'		=> array(),
+			'qb_cache_orderby'		=> array(),
+			'qb_cache_set'			=> array(),
+			'qb_cache_exists'		=> array(),
+			'qb_cache_no_escape'	=> array()
 		));
 	}
 
@@ -2206,47 +2218,47 @@
 	/**
 	 * Merge Cache
 	 *
-	 * When called, this function merges any cached AR arrays with
+	 * When called, this function merges any cached QB arrays with
 	 * locally called ones.
 	 *
 	 * @return	void
 	 */
 	protected function _merge_cache()
 	{
-		if (count($this->ar_cache_exists) === 0)
+		if (count($this->qb_cache_exists) === 0)
 		{
 			return;
 		}
 
-		foreach ($this->ar_cache_exists as $val)
+		foreach ($this->qb_cache_exists as $val)
 		{
-			$ar_variable	= 'ar_'.$val;
-			$ar_cache_var	= 'ar_cache_'.$val;
+			$qb_variable	= 'qb_'.$val;
+			$qb_cache_var	= 'qb_cache_'.$val;
 
-			if (count($this->$ar_cache_var) === 0)
+			if (count($this->$qb_cache_var) === 0)
 			{
 				continue;
 			}
 
-			$this->$ar_variable = array_unique(array_merge($this->$ar_cache_var, $this->$ar_variable));
+			$this->$qb_variable = array_unique(array_merge($this->$qb_cache_var, $this->$qb_variable));
 		}
 
 		// If we are "protecting identifiers" we need to examine the "from"
 		// portion of the query to determine if there are any aliases
-		if ($this->_protect_identifiers === TRUE && count($this->ar_cache_from) > 0)
+		if ($this->_protect_identifiers === TRUE && count($this->qb_cache_from) > 0)
 		{
-			$this->_track_aliases($this->ar_from);
+			$this->_track_aliases($this->qb_from);
 		}
 
-		$this->ar_no_escape = $this->ar_cache_no_escape;
+		$this->qb_no_escape = $this->qb_cache_no_escape;
 	}
 
 	// --------------------------------------------------------------------
 
 	/**
-	 * Reset Active Record values.
+	 * Reset Query Builder values.
 	 *
-	 * Publicly-visible method to reset the AR values.
+	 * Publicly-visible method to reset the QB values.
 	 *
 	 * @return	void
 	 */
@@ -2259,16 +2271,16 @@
 	// --------------------------------------------------------------------
 
 	/**
-	 * Resets the active record values.  Called by the get() function
+	 * Resets the query builder values.  Called by the get() function
 	 *
 	 * @param	array	An array of fields to reset
 	 * @return	void
 	 */
-	protected function _reset_run($ar_reset_items)
+	protected function _reset_run($qb_reset_items)
 	{
-		foreach ($ar_reset_items as $item => $default_value)
+		foreach ($qb_reset_items as $item => $default_value)
 		{
-			if ( ! in_array($item, $this->ar_store_array))
+			if ( ! in_array($item, $this->qb_store_array))
 			{
 				$this->$item = $default_value;
 			}
@@ -2278,28 +2290,28 @@
 	// --------------------------------------------------------------------
 
 	/**
-	 * Resets the active record values.  Called by the get() function
+	 * Resets the query builder values.  Called by the get() function
 	 *
 	 * @return	void
 	 */
 	protected function _reset_select()
 	{
 		$this->_reset_run(array(
-					'ar_select'		=> array(),
-					'ar_from'		=> array(),
-					'ar_join'		=> array(),
-					'ar_where'		=> array(),
-					'ar_like'		=> array(),
-					'ar_groupby'		=> array(),
-					'ar_having'		=> array(),
-					'ar_orderby'		=> array(),
-					'ar_wherein'		=> array(),
-					'ar_aliased_tables'	=> array(),
-					'ar_no_escape'		=> array(),
-					'ar_distinct'		=> FALSE,
-					'ar_limit'		=> FALSE,
-					'ar_offset'		=> FALSE,
-					'ar_order'		=> FALSE
+					'qb_select'		=> array(),
+					'qb_from'		=> array(),
+					'qb_join'		=> array(),
+					'qb_where'		=> array(),
+					'qb_like'		=> array(),
+					'qb_groupby'		=> array(),
+					'qb_having'		=> array(),
+					'qb_orderby'		=> array(),
+					'qb_wherein'		=> array(),
+					'qb_aliased_tables'	=> array(),
+					'qb_no_escape'		=> array(),
+					'qb_distinct'		=> FALSE,
+					'qb_limit'		=> FALSE,
+					'qb_offset'		=> FALSE,
+					'qb_order'		=> FALSE
 					)
 				);
 	}
@@ -2307,7 +2319,7 @@
 	// --------------------------------------------------------------------
 
 	/**
-	 * Resets the active record "write" values.
+	 * Resets the query builder "write" values.
 	 *
 	 * Called by the insert() update() insert_batch() update_batch() and delete() functions
 	 *
@@ -2316,19 +2328,19 @@
 	protected function _reset_write()
 	{
 		$this->_reset_run(array(
-			'ar_set'	=> array(),
-			'ar_from'	=> array(),
-			'ar_where'	=> array(),
-			'ar_like'	=> array(),
-			'ar_orderby'	=> array(),
-			'ar_keys'	=> array(),
-			'ar_limit'	=> FALSE,
-			'ar_order'	=> FALSE
+			'qb_set'	=> array(),
+			'qb_from'	=> array(),
+			'qb_where'	=> array(),
+			'qb_like'	=> array(),
+			'qb_orderby'	=> array(),
+			'qb_keys'	=> array(),
+			'qb_limit'	=> FALSE,
+			'qb_order'	=> FALSE
 			)
 		);
 	}
 
 }
 
-/* End of file DB_active_rec.php */
-/* Location: ./system/database/DB_active_rec.php */
\ No newline at end of file
+/* End of file DB_query_builder.php */
+/* Location: ./system/database/DB_query_builder.php */
\ No newline at end of file
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index 7a5c048..c5018bf 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -29,7 +29,7 @@
  * CUBRID Database Adapter Class
  *
  * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
+ * creates dynamically based on whether the query builder
  * class is being used or not.
  *
  * @package		CodeIgniter
@@ -508,7 +508,7 @@
 	}
 
 	// --------------------------------------------------------------------
-
+	
 	/**
 	 * Limit string
 	 *
@@ -549,4 +549,4 @@
 }
 
 /* End of file cubrid_driver.php */
-/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */
diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php
index 6587d72..1b18de8 100644
--- a/system/database/drivers/interbase/interbase_driver.php
+++ b/system/database/drivers/interbase/interbase_driver.php
@@ -29,7 +29,7 @@
  * Firebird/Interbase Database Adapter Class
  *
  * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
+ * creates dynamically based on whether the query builder
  * class is being used or not.
  *
  * @package		CodeIgniter
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 90609a8..f60ec81 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -29,7 +29,7 @@
  * MS SQL Database Adapter Class
  *
  * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
+ * creates dynamically based on whether the query builder
  * class is being used or not.
  *
  * @package		CodeIgniter
@@ -534,4 +534,4 @@
 }
 
 /* End of file mssql_driver.php */
-/* Location: ./system/database/drivers/mssql/mssql_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/mssql/mssql_driver.php */
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index c2fccc1..32c5186 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -29,7 +29,7 @@
  * MySQL Database Adapter Class
  *
  * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
+ * creates dynamically based on whether the query builder
  * class is being used or not.
  *
  * @package		CodeIgniter
@@ -531,4 +531,4 @@
 }
 
 /* End of file mysql_driver.php */
-/* Location: ./system/database/drivers/mysql/mysql_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/mysql/mysql_driver.php */
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index a690682..e2684e4 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -29,7 +29,7 @@
  * MySQLi Database Adapter Class
  *
  * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
+ * creates dynamically based on whether the query builder
  * class is being used or not.
  *
  * @package		CodeIgniter
@@ -535,4 +535,4 @@
 }
 
 /* End of file mysqli_driver.php */
-/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 1b66178..33a89df 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -29,7 +29,7 @@
  * oci8 Database Adapter Class
  *
  * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
+ * creates dynamically based on whether the query builder
  * class is being used or not.
  *
  * @package		CodeIgniter
@@ -682,4 +682,4 @@
 }
 
 /* End of file oci8_driver.php */
-/* Location: ./system/database/drivers/oci8/oci8_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/oci8/oci8_driver.php */
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 38416cf..e36f2d2 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -29,7 +29,7 @@
  * ODBC Database Adapter Class
  *
  * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
+ * creates dynamically based on whether the query builder
  * class is being used or not.
  *
  * @package		CodeIgniter
@@ -413,4 +413,4 @@
 }
 
 /* End of file odbc_driver.php */
-/* Location: ./system/database/drivers/odbc/odbc_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/odbc/odbc_driver.php */
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 60151b9..89e6967 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -29,7 +29,7 @@
  * PDO Database Adapter Class
  *
  * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
+ * creates dynamically based on whether the query builder
  * class is being used or not.
  *
  * @package		CodeIgniter
@@ -225,7 +225,7 @@
 		 *
 		 * Reference: http://www.php.net/manual/en/ref.pdo-mysql.connection.php
 		 */
-		if ($this->subdriver === 'mysql' && ! is_php('5.3.6') && ! empty($this->char_set))
+		if ($this->pdodriver === 'mysql' && ! is_php('5.3.6') && ! empty($this->char_set))
 		{
 			$this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES '.$this->char_set
 					.( ! empty($this->db_collat) ? " COLLATE '".$this->dbcollat."'" : '');
@@ -683,4 +683,4 @@
 }
 
 /* End of file pdo_driver.php */
-/* Location: ./system/database/drivers/pdo/pdo_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/pdo/pdo_driver.php */
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 14259be..d858f01 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -29,7 +29,7 @@
  * Postgre Database Adapter Class
  *
  * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
+ * creates dynamically based on whether the query builder
  * class is being used or not.
  *
  * @package		CodeIgniter
@@ -569,4 +569,4 @@
 }
 
 /* End of file postgre_driver.php */
-/* Location: ./system/database/drivers/postgre/postgre_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/postgre/postgre_driver.php */
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 5021deb..551704f 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -29,7 +29,7 @@
  * SQLite Database Adapter Class
  *
  * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
+ * creates dynamically based on whether the query builder
  * class is being used or not.
  *
  * @package		CodeIgniter
@@ -461,4 +461,4 @@
 }
 
 /* End of file sqlite_driver.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */
diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php
index fb45bee..d22f6a4 100644
--- a/system/database/drivers/sqlite3/sqlite3_driver.php
+++ b/system/database/drivers/sqlite3/sqlite3_driver.php
@@ -29,7 +29,7 @@
  * SQLite3 Database Adapter Class
  *
  * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
+ * creates dynamically based on whether the query builder
  * class is being used or not.
  *
  * @package		CodeIgniter
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 9515670..8cc500f 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -29,7 +29,7 @@
  * SQLSRV Database Adapter Class
  *
  * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
+ * creates dynamically based on whether the query builder
  * class is being used or not.
  *
  * @package		CodeIgniter
@@ -440,7 +440,7 @@
 			$where .= ($where === '' ? ' WHERE ' : ' AND ').implode(' ', $like);
 		}
 
-		return 'UPDATE '.$table.' SET '.implode(', ', $valstr).' WHERE '.$where;
+		return 'UPDATE '.$table.' SET '.implode(', ', $valstr).$where;
 	}
 
 	// --------------------------------------------------------------------
@@ -521,4 +521,4 @@
 }
 
 /* End of file sqlsrv_driver.php */
-/* Location: ./system/database/drivers/sqlsrv/sqlsrv_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_driver.php */
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 19192a1..8b87f81 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -100,6 +100,9 @@
 			$x[count($x) - 1] = strtoupper($extension);
 			$filename = implode('.', $x);
 		}
+		
+		// Clean output buffer
+		ob_clean();
 
 		// Generate the server headers
 		header('Content-Type: '.$mime);
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 3a373ef..a5aabec 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -145,7 +145,7 @@
 				{
 					delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1, $htdocs);
 				}
-				elseif ($htdocs === TRUE && ! preg_match('/^(\.htaccess|index\.(html|htm|php))$/', $filename))
+				elseif ($htdocs === TRUE && ! preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename))
 				{
 					@unlink($path.DIRECTORY_SEPARATOR.$filename);
 				}
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 48c3bf3..103c3cb 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1891,6 +1891,7 @@
 						'tiff'	=>	'image/tiff',
 						'tif'	=>	'image/tiff',
 						'css'	=>	'text/css',
+						'ics'	=>	'text/calendar',
 						'html'	=>	'text/html',
 						'htm'	=>	'text/html',
 						'shtml'	=>	'text/html',
diff --git a/tests/codeigniter/database/DB_driver_test.php b/tests/codeigniter/database/DB_driver_test.php
new file mode 100644
index 0000000..fb40f06
--- /dev/null
+++ b/tests/codeigniter/database/DB_driver_test.php
@@ -0,0 +1,36 @@
+<?php
+
+class DB_driver_test extends CI_TestCase {
+
+	// ------------------------------------------------------------------------
+
+	public function test_initialize()
+	{
+		$config = Mock_Database_DB::config(DB_DRIVER);
+		$driver_name = current(explode('/', DB_DRIVER));
+		$driver = $this->$driver_name($config[DB_DRIVER]);
+
+		$this->assertTrue($driver->initialize());
+	}
+
+	protected function pdo($config)
+	{
+		return new Mock_Database_Drivers_PDO($config);
+	}
+
+	protected function mysql($config)
+	{
+		return new Mock_Database_Drivers_Mysql($config);
+	}
+
+	protected function sqlite($config)
+	{
+		return new Mock_Database_Drivers_Sqlite($config);
+	}
+
+	protected function pgsql($config)
+	{
+		return new Mock_Database_Drivers_Postgre($config);
+	}
+	
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/.gitkeep b/tests/codeigniter/database/query_builder/.gitkeep
deleted file mode 100644
index e69de29..0000000
--- a/tests/codeigniter/database/query_builder/.gitkeep
+++ /dev/null
diff --git a/tests/codeigniter/database/query_builder/get_test.php b/tests/codeigniter/database/query_builder/get_test.php
new file mode 100644
index 0000000..0751c93
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/get_test.php
@@ -0,0 +1,53 @@
+<?php
+
+class Get_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_get_simple()
+	{
+		$jobs = $this->db->get('job')->result_array();
+		
+		// Dummy jobs contain 4 rows
+		$this->assertCount(4, $jobs);
+
+		// Check rows item
+		$this->assertEquals('Developer', $jobs[0]['name']);
+		$this->assertEquals('Politician', $jobs[1]['name']);
+		$this->assertEquals('Accountant', $jobs[2]['name']);
+		$this->assertEquals('Musician', $jobs[3]['name']);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_get_where()
+	{
+		$job1 = $this->db->get('job', array('id' => 1))->result_array();
+		
+		// Dummy jobs contain 1 rows
+		$this->assertCount(1, $job1);
+
+		// Check rows item
+		$this->assertEquals('Developer', $job1[0]['name']);
+	}
+	
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/insert_test.php b/tests/codeigniter/database/query_builder/insert_test.php
new file mode 100644
index 0000000..53ce23c
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/insert_test.php
@@ -0,0 +1,67 @@
+<?php
+
+class Insert_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+
+		// Truncate the current datas
+		$this->db->truncate('job');
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_insert()
+	{
+		$job_data = array('id' => 1, 'name' => 'Grocery Sales', 'description' => 'Discount!');
+		
+		// Do normal insert
+		$this->assertTrue($this->db->insert('job', $job_data));
+
+		$jobs = $this->db->get('job')->result_array();
+		$job1 = $jobs[0];
+
+		// Check the result
+		$this->assertEquals('Grocery Sales', $job1['name']);
+
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_insert_batch()
+	{
+		$job_datas = array(
+			array('id' => 2, 'name' => 'Commedian', 'description' => 'Theres something in your teeth'), 
+			array('id' => 3, 'name' => 'Cab Driver', 'description' => 'Iam yellow'),
+		);
+		
+		// Do insert batch except for sqlite driver
+		if (strpos(DB_DRIVER, 'sqlite') === FALSE)
+		{
+			$this->assertTrue($this->db->insert_batch('job', $job_datas));
+
+			$job_2 = $this->db->where('id', 2)->get('job')->row();
+			$job_3 = $this->db->where('id', 3)->get('job')->row();
+
+			// Check the result
+			$this->assertEquals('Commedian', $job_2->name);
+			$this->assertEquals('Cab Driver', $job_3->name);
+		}
+	}
+	
+}
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/select_test.php b/tests/codeigniter/database/query_builder/select_test.php
new file mode 100644
index 0000000..dbf432a
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/select_test.php
@@ -0,0 +1,95 @@
+<?php
+
+class Select_test extends CI_TestCase {
+
+	/**
+	 * @var object Database/Query Builder holder
+	 */
+	protected $db;
+
+	public function set_up()
+	{
+		$this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+		Mock_Database_Schema_Skeleton::create_tables();
+		Mock_Database_Schema_Skeleton::create_data();
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_select_only_one_collumn()
+	{
+		$jobs_name = $this->db->select('name')
+		                      ->get('job')
+		                      ->result_array();
+		
+		// Check rows item
+		$this->assertArrayHasKey('name',$jobs_name[0]);
+		$this->assertFalse(array_key_exists('id', $jobs_name[0]));
+		$this->assertFalse(array_key_exists('description', $jobs_name[0]));
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_select_min()
+	{
+		$job_min = $this->db->select_min('id')
+		                    ->get('job')
+		                    ->result_array();
+		
+		// Minimum id was 1
+		$this->assertEquals('1', $job_min[0]['id']);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_select_max()
+	{
+		$job_max = $this->db->select_max('id')
+		                    ->get('job')
+		                    ->result_array();
+		
+		// Maximum id was 4
+		$this->assertEquals('4', $job_max[0]['id']);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_select_avg()
+	{
+		$job_avg = $this->db->select_avg('id')
+		                    ->get('job')
+		                    ->result_array();
+		
+		// Average should be 2.5
+		$this->assertEquals('2.5', $job_avg[0]['id']);
+	}
+
+	// ------------------------------------------------------------------------
+
+	/**
+	 * @see ./mocks/schema/skeleton.php
+	 */
+	public function test_select_sum()
+	{
+		$job_sum = $this->db->select_sum('id')
+		                    ->get('job')
+		                    ->result_array();
+		
+		// Sum of ids should be 10
+		$this->assertEquals('10', $job_sum[0]['id']);
+	}
+	
+}
\ No newline at end of file
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
index dd59292..f1bdb5d 100644
--- a/tests/mocks/autoloader.php
+++ b/tests/mocks/autoloader.php
@@ -53,13 +53,24 @@
 			$dir = BASEPATH.'libraries'.DIRECTORY_SEPARATOR;
 			$class = $subclass;
 		}
+		elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) == 3)
+		{
+			$driver_path = BASEPATH.'database'.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR;
+			$dir = $driver_path.$m[1].DIRECTORY_SEPARATOR;
+			$file = $dir.$m[1].'_'.$m[2].'.php';
+		}
+		elseif (strpos($class, 'CI_DB') === 0)
+		{
+			$dir = BASEPATH.'database'.DIRECTORY_SEPARATOR;
+			$file = $dir.str_replace(array('CI_DB','active_record'), array('DB', 'active_rec'), $subclass).'.php';
+		}
 		else
 		{
 			$class = strtolower($class);
 		}
 	}
 
-	$file = $dir.$class.'.php';
+	$file = (isset($file)) ? $file : $dir.$class.'.php';
 
 	if ( ! file_exists($file))
 	{
@@ -71,7 +82,7 @@
 		{
 			return FALSE;
 		}
-
+		
 	    throw new InvalidArgumentException("Unable to load $class.");
 	}
 
diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite
index 37ce4f8..86d868a 100755
--- a/tests/mocks/database/ci_test.sqlite
+++ b/tests/mocks/database/ci_test.sqlite
Binary files differ
diff --git a/tests/mocks/database/config/pdo/mysql.php b/tests/mocks/database/config/pdo/mysql.php
new file mode 100644
index 0000000..cefb6b0
--- /dev/null
+++ b/tests/mocks/database/config/pdo/mysql.php
@@ -0,0 +1,37 @@
+<?php
+
+return array(
+	
+	// Typical Database configuration
+	'pdo/mysql' => array(
+		'dsn' => '',
+		'hostname' => 'localhost',
+		'username' => 'travis',
+		'password' => '',
+		'database' => 'ci_test',
+		'dbdriver' => 'pdo',
+		'pdodriver' => 'mysql',
+	),
+
+	// Database configuration with failover
+	'pdo/mysql_failover' => array(
+		'dsn' => '',
+		'hostname' => 'localhost',
+		'username' => 'not_travis',
+		'password' => 'wrong password',
+		'database' => 'not_ci_test',
+		'dbdriver' => 'pdo',
+		'pdodriver' => 'mysql',
+		'failover' => array(
+			array(
+				'dsn' => '',
+				'hostname' => 'localhost',
+				'username' => 'travis',
+				'password' => '',
+				'database' => 'ci_test',
+				'dbdriver' => 'pdo',
+				'pdodriver' => 'mysql',
+			),
+		),
+	),
+);
\ No newline at end of file
diff --git a/tests/mocks/database/config/pdo/pgsql.php b/tests/mocks/database/config/pdo/pgsql.php
new file mode 100644
index 0000000..5196e9a
--- /dev/null
+++ b/tests/mocks/database/config/pdo/pgsql.php
@@ -0,0 +1,37 @@
+<?php
+
+return array(
+	
+	// Typical Database configuration
+	'pdo/pgsql' => array(
+		'dsn' => 'pgsql:host=localhost;port=5432;dbname=ci_test;',
+		'hostname' => 'localhost',
+		'username' => 'postgres',
+		'password' => '',
+		'database' => 'ci_test',
+		'dbdriver' => 'pdo',
+		'pdodriver' => 'pgsql',
+	),
+
+	// Database configuration with failover
+	'pdo/pgsql_failover' => array(
+		'dsn' => '',
+		'hostname' => 'localhost',
+		'username' => 'not_travis',
+		'password' => 'wrong password',
+		'database' => 'not_ci_test',
+		'dbdriver' => 'pdo',
+		'pdodriver' => 'pgsql',
+		'failover' => array(
+			array(
+				'dsn' => 'pgsql:host=localhost;port=5432;dbname=ci_test;',
+				'hostname' => 'localhost',
+				'username' => 'postgres',
+				'password' => '',
+				'database' => 'ci_test',
+				'dbdriver' => 'pdo',
+				'pdodriver' => 'pgsql',
+			),
+		),
+	),
+);
\ No newline at end of file
diff --git a/tests/mocks/database/config/pdo/sqlite.php b/tests/mocks/database/config/pdo/sqlite.php
new file mode 100644
index 0000000..c68b4b2
--- /dev/null
+++ b/tests/mocks/database/config/pdo/sqlite.php
@@ -0,0 +1,37 @@
+<?php
+
+return array(
+
+	// Typical Database configuration
+	'pdo/sqlite' => array(
+		'dsn' => 'sqlite:/'.realpath(__DIR__.'/../..').'/ci_test.sqlite',
+		'hostname' => 'localhost',
+		'username' => 'sqlite',
+		'password' => 'sqlite',
+		'database' => 'sqlite',
+		'dbdriver' => 'pdo',
+		'pdodriver' => 'sqlite',
+	),
+
+	// Database configuration with failover
+	'pdo/sqlite_failover' => array(
+		'dsn' => 'sqlite:not_exists.sqlite',
+		'hostname' => 'localhost',
+		'username' => 'sqlite',
+		'password' => 'sqlite',
+		'database' => 'sqlite',
+		'dbdriver' => 'pdo',
+		'pdodriver' => 'sqlite',
+		'failover' => array(
+			array(
+				'dsn' => 'sqlite:/'.realpath(__DIR__.'/../..').'/ci_test.sqlite',
+				'hostname' => 'localhost',
+				'username' => 'sqlite',
+				'password' => 'sqlite',
+				'database' => 'sqlite',
+				'dbdriver' => 'pdo', 
+				'pdodriver' => 'sqlite',
+			),
+		),
+	),
+);
\ No newline at end of file
diff --git a/tests/mocks/database/config/sqlite.php b/tests/mocks/database/config/sqlite.php
index 8665e20..755ce2a 100644
--- a/tests/mocks/database/config/sqlite.php
+++ b/tests/mocks/database/config/sqlite.php
@@ -1,5 +1,4 @@
 <?php
-$dbdriver = is_php('5.4') ? 'sqlite3' : 'sqlite';
 
 return array(
 
@@ -10,7 +9,7 @@
 		'username' => 'sqlite',
 		'password' => 'sqlite',
 		'database' => realpath(__DIR__.'/..').'/ci_test.sqlite',
-		'dbdriver' => $dbdriver,
+		'dbdriver' => 'sqlite3',
 	),
 
 	// Database configuration with failover
@@ -20,15 +19,15 @@
 		'username' => 'sqlite',
 		'password' => 'sqlite',
 		'database' => '../not_exists.sqlite',
-		'dbdriver' => $dbdriver,
+		'dbdriver' => 'sqlite3',
 		'failover' => array(
 			array(
 				'dsn' => '',
 				'hostname' => 'localhost',
 				'username' => 'sqlite',
 				'password' => 'sqlite',
-				'database' => realpath(__DIR__.'/..').'/ci_testf.sqlite',
-				'dbdriver' => $dbdriver,
+				'database' => realpath(__DIR__.'/..').'/ci_test.sqlite',
+				'dbdriver' => 'sqlite3',
 			),
 		),
 	),
diff --git a/tests/mocks/database/db.php b/tests/mocks/database/db.php
index 43a0d39..59028ed 100644
--- a/tests/mocks/database/db.php
+++ b/tests/mocks/database/db.php
@@ -45,19 +45,18 @@
 		);
 
 		$config = array_merge($this->config[$group], $params);
+		$dsnstring = ( ! empty($config['dsn'])) ? $config['dsn'] : FALSE;
+		$pdodriver = ( ! empty($config['pdodriver'])) ? $config['pdodriver'] : FALSE;
+		$failover = ( ! empty($config['failover'])) ? $config['failover'] : FALSE;
 
-		if ( ! empty($config['dsn']))
-		{
-			$dsn = $config['dsn'];
-		}
-		else
-		{
-			$dsn = $config['dbdriver'].'://'.$config['username'].':'.$config['password']
+		$dsn = $config['dbdriver'].'://'.$config['username'].':'.$config['password']
 			       .'@'.$config['hostname'].'/'.$config['database'];
 
-		}
-
+		// Build the parameter
 		$other_params = array_slice($config, 6);
+		if ($dsnstring) $other_params['dsn'] = $dsnstring;
+		if ($pdodriver) $other_params['pdodriver'] = $pdodriver;
+		if ($failover) $other_params['failover'] = $failover;
 
 		return $dsn.'?'.http_build_query($other_params);
 	}
diff --git a/tests/mocks/database/db/driver.php b/tests/mocks/database/db/driver.php
new file mode 100644
index 0000000..cb18202
--- /dev/null
+++ b/tests/mocks/database/db/driver.php
@@ -0,0 +1,36 @@
+<?php
+
+class Mock_Database_DB_Driver extends CI_DB_driver {
+	
+	/**
+	 * @var object The actual Driver
+	 */
+	protected $ci_db_driver;
+
+	/**
+	 * Instantiate the database driver
+	 *
+	 * @param  string 	DB Driver class name
+	 * @param  array 	DB configuration to set
+	 * @return void
+	 */
+	public function __construct($driver_class, $config = array())
+	{
+		if (is_string($driver_class)) $this->ci_db_driver = new $driver_class($config);
+	}
+
+	/**
+	 * Overloading method, emulate the actual driver method (multiple inheritance workaround)
+	 */
+	public function __call($method, $arguments)
+	{
+		if ( ! is_callable(array($this->ci_db_driver, $method)))
+		{
+			throw new BadMethodCallException($method. ' not exists or not implemented');
+		}
+
+		return call_user_func_array(array($this->ci_db_driver, $method), $arguments);
+	}
+}
+
+class CI_DB extends Mock_Database_DB_QueryBuilder {}
\ No newline at end of file
diff --git a/tests/mocks/database/db/querybuilder.php b/tests/mocks/database/db/querybuilder.php
new file mode 100644
index 0000000..1b95c92
--- /dev/null
+++ b/tests/mocks/database/db/querybuilder.php
@@ -0,0 +1,10 @@
+<?php
+
+if ( ! class_exists('CI_DB_query_builder'))
+{
+	class Mock_Database_DB_QueryBuilder extends CI_DB_active_record {}
+}
+else
+{
+	class Mock_Database_DB_QueryBuilder extends CI_DB_query_builder {}
+}
diff --git a/tests/mocks/database/drivers/mysql.php b/tests/mocks/database/drivers/mysql.php
new file mode 100644
index 0000000..34a74e2
--- /dev/null
+++ b/tests/mocks/database/drivers/mysql.php
@@ -0,0 +1,16 @@
+<?php
+
+class Mock_Database_Drivers_Mysql extends Mock_Database_DB_Driver {
+	
+	/**
+	 * Instantiate the database driver
+	 *
+	 * @param  string 	DB Driver class name
+	 * @param  array 	DB configuration to set
+	 * @return void
+	 */
+	public function __construct($config = array())
+	{
+		parent::__construct('CI_DB_mysql_driver', $config);
+	}
+}
\ No newline at end of file
diff --git a/tests/mocks/database/drivers/pdo.php b/tests/mocks/database/drivers/pdo.php
new file mode 100644
index 0000000..590e195
--- /dev/null
+++ b/tests/mocks/database/drivers/pdo.php
@@ -0,0 +1,16 @@
+<?php
+
+class Mock_Database_Drivers_PDO extends Mock_Database_DB_Driver {
+	
+	/**
+	 * Instantiate the database driver
+	 *
+	 * @param  string 	DB Driver class name
+	 * @param  array 	DB configuration to set
+	 * @return void
+	 */
+	public function __construct($config = array())
+	{
+		parent::__construct('CI_DB_pdo_driver', $config);
+	}
+}
\ No newline at end of file
diff --git a/tests/mocks/database/drivers/postgre.php b/tests/mocks/database/drivers/postgre.php
new file mode 100644
index 0000000..0df9059
--- /dev/null
+++ b/tests/mocks/database/drivers/postgre.php
@@ -0,0 +1,16 @@
+<?php
+
+class Mock_Database_Drivers_Postgre extends Mock_Database_DB_Driver {
+	
+	/**
+	 * Instantiate the database driver
+	 *
+	 * @param  string 	DB Driver class name
+	 * @param  array 	DB configuration to set
+	 * @return void
+	 */
+	public function __construct($config = array())
+	{
+		parent::__construct('CI_DB_postgre_driver', $config);
+	}
+}
\ No newline at end of file
diff --git a/tests/mocks/database/drivers/sqlite.php b/tests/mocks/database/drivers/sqlite.php
new file mode 100644
index 0000000..76a182c
--- /dev/null
+++ b/tests/mocks/database/drivers/sqlite.php
@@ -0,0 +1,16 @@
+<?php
+
+class Mock_Database_Drivers_Sqlite extends Mock_Database_DB_Driver {
+	
+	/**
+	 * Instantiate the database driver
+	 *
+	 * @param  string 	DB Driver class name
+	 * @param  array 	DB configuration to set
+	 * @return void
+	 */
+	public function __construct($config = array())
+	{
+		parent::__construct('CI_DB_sqlite3_driver', $config);
+	}
+}
\ No newline at end of file
diff --git a/tests/mocks/database/schema/.gitkeep b/tests/mocks/database/schema/.gitkeep
deleted file mode 100644
index e69de29..0000000
--- a/tests/mocks/database/schema/.gitkeep
+++ /dev/null
diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php
new file mode 100644
index 0000000..a3d5bac
--- /dev/null
+++ b/tests/mocks/database/schema/skeleton.php
@@ -0,0 +1,98 @@
+<?php
+
+class Mock_Database_Schema_Skeleton {
+
+	/**
+	 * @var object Database Holder
+	 */
+	public static $db;
+
+	/**
+	 * @var object Forge Holder
+	 */
+	public static $forge;
+
+	/**
+	 * @var object Driver Holder
+	 */
+	public static $driver;
+
+	/**
+	 * Initialize both database and forge components
+	 */
+	public static function init($driver)
+	{
+		if (empty(static::$db) && empty(static::$forge))
+		{
+			$config = Mock_Database_DB::config($driver);
+			$connection = new Mock_Database_DB($config);
+			$db = Mock_Database_DB::DB($connection->set_dsn($driver), TRUE);
+
+			CI_TestCase::instance()->ci_instance_var('db', $db);
+
+			$loader = new Mock_Core_Loader();
+			$loader->dbforge();
+			$forge = CI_TestCase::instance()->ci_instance_var('dbforge');
+
+			static::$db = $db;
+			static::$forge = $forge;
+			static::$driver = $driver;
+		}
+
+		return static::$db;
+	}
+	
+	
+	/**
+	 * Create the dummy tables
+	 *
+	 * @return void
+	 */
+	public static function create_tables()
+	{
+		// Job Table
+		static::$forge->add_field(array(
+			'id' => array(
+				'type' => 'INTEGER',
+				'constraint' => 3,
+			),
+			'name' => array(
+				'type' => 'VARCHAR',
+				'constraint' => 40,
+			),
+			'description' => array(
+				'type' => 'TEXT',
+			),
+		));
+		static::$forge->add_key('id', TRUE);
+		static::$forge->create_table('job', (strpos(static::$driver, 'pgsql') === FALSE));
+	}
+
+	/**
+	 * Create the dummy datas
+	 *
+	 * @return void
+	 */
+	public static function create_data()
+	{
+		// Job Data
+		$data = array(
+			'job' => array(
+				array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'), 
+				array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'),
+    			array('id' => 3, 'name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'),
+			    array('id' => 4, 'name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician'),
+			),
+		);
+
+		foreach ($data as $table => $dummy_data) 
+		{
+			static::$db->truncate($table);
+
+			foreach ($dummy_data as $single_dummy_data)
+			{
+				static::$db->insert($table, $single_dummy_data); 
+			}
+		}
+	}
+}
\ No newline at end of file
diff --git a/tests/travis/mysql.phpunit.xml b/tests/travis/mysql.phpunit.xml
index 44d6d6e..e9556f7 100644
--- a/tests/travis/mysql.phpunit.xml
+++ b/tests/travis/mysql.phpunit.xml
@@ -28,10 +28,5 @@
 			<directory suffix=".php">PROJECT_BASE.'tests'</directory>
 			<directory suffix=".php">'../../system/core/CodeIgniter.php'</directory>
 		</blacklist>
-		<whitelist>
-			<!--
-			<directory suffix=".php">'../system/core'</directory>
-			-->
-		</whitelist>
 	</filters>
 </phpunit>
\ No newline at end of file
diff --git a/tests/travis/pdo/mysql.phpunit.xml b/tests/travis/pdo/mysql.phpunit.xml
new file mode 100644
index 0000000..69eece2
--- /dev/null
+++ b/tests/travis/pdo/mysql.phpunit.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit 
+	bootstrap="../../Bootstrap.php"
+	colors="true"
+	convertNoticesToExceptions="true"
+	convertWarningsToExceptions="true"
+	stopOnError="false"
+	stopOnFailure="false"
+	stopOnIncomplete="false"
+	stopOnSkipped="false">
+	<php>
+        <const name="DB_DRIVER" value="pdo/mysql"/>
+    </php>
+	<testsuites>
+		<testsuite name="CodeIgniter Core Test Suite">
+			<file>../../codeigniter/Setup_test.php</file>
+			<directory suffix="test.php">../../codeigniter/core</directory>
+			<directory suffix="test.php">../../codeigniter/helpers</directory>
+			<directory suffix="test.php">../../codeigniter/libraries</directory>
+			<directory suffix="test.php">../../codeigniter/database</directory>
+		</testsuite>
+	</testsuites>
+	<filters>
+		<blacklist>
+			<directory suffix=".php">PEAR_INSTALL_DIR</directory>
+			<directory suffix=".php">PHP_LIBDIR</directory>
+			<directory suffix=".php">PROJECT_BASE.'tests'</directory>
+			<directory suffix=".php">'../../../system/core/CodeIgniter.php'</directory>
+		</blacklist>
+	</filters>
+</phpunit>
\ No newline at end of file
diff --git a/tests/travis/pdo/pgsql.phpunit.xml b/tests/travis/pdo/pgsql.phpunit.xml
new file mode 100644
index 0000000..e68c3e0
--- /dev/null
+++ b/tests/travis/pdo/pgsql.phpunit.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit 
+	bootstrap="../../Bootstrap.php"
+	colors="true"
+	convertNoticesToExceptions="true"
+	convertWarningsToExceptions="true"
+	stopOnError="false"
+	stopOnFailure="false"
+	stopOnIncomplete="false"
+	stopOnSkipped="false">
+	<php>
+        <const name="DB_DRIVER" value="pdo/pgsql"/>
+    </php>
+	<testsuites>
+		<testsuite name="CodeIgniter Core Test Suite">
+			<file>../../codeigniter/Setup_test.php</file>
+			<directory suffix="test.php">../../codeigniter/core</directory>
+			<directory suffix="test.php">../../codeigniter/helpers</directory>
+			<directory suffix="test.php">../../codeigniter/libraries</directory>
+			<directory suffix="test.php">../../codeigniter/database</directory>
+		</testsuite>
+	</testsuites>
+	<filters>
+		<blacklist>
+			<directory suffix=".php">PEAR_INSTALL_DIR</directory>
+			<directory suffix=".php">PHP_LIBDIR</directory>
+			<directory suffix=".php">PROJECT_BASE.'tests'</directory>
+			<directory suffix=".php">'../../../system/core/CodeIgniter.php'</directory>
+		</blacklist>
+	</filters>
+</phpunit>
\ No newline at end of file
diff --git a/tests/travis/pdo/sqlite.phpunit.xml b/tests/travis/pdo/sqlite.phpunit.xml
new file mode 100644
index 0000000..1871f62
--- /dev/null
+++ b/tests/travis/pdo/sqlite.phpunit.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit 
+	bootstrap="../../Bootstrap.php"
+	colors="true"
+	convertNoticesToExceptions="true"
+	convertWarningsToExceptions="true"
+	stopOnError="false"
+	stopOnFailure="false"
+	stopOnIncomplete="false"
+	stopOnSkipped="false">
+	<php>
+        <const name="DB_DRIVER" value="pdo/sqlite"/>
+    </php>
+	<testsuites>
+		<testsuite name="CodeIgniter Core Test Suite">
+			<file>../../codeigniter/Setup_test.php</file>
+			<directory suffix="test.php">../../codeigniter/core</directory>
+			<directory suffix="test.php">../../codeigniter/helpers</directory>
+			<directory suffix="test.php">../../codeigniter/libraries</directory>
+			<directory suffix="test.php">../../codeigniter/database</directory>
+		</testsuite>
+	</testsuites>
+	<filters>
+		<blacklist>
+			<directory suffix=".php">PEAR_INSTALL_DIR</directory>
+			<directory suffix=".php">PHP_LIBDIR</directory>
+			<directory suffix=".php">PROJECT_BASE.'tests'</directory>
+			<directory suffix=".php">'../../../system/core/CodeIgniter.php'</directory>
+		</blacklist>
+	</filters>
+</phpunit>
\ No newline at end of file
diff --git a/tests/travis/pgsql.phpunit.xml b/tests/travis/pgsql.phpunit.xml
index 9f52b40..ad8aede 100644
--- a/tests/travis/pgsql.phpunit.xml
+++ b/tests/travis/pgsql.phpunit.xml
@@ -28,10 +28,5 @@
 			<directory suffix=".php">PROJECT_BASE.'tests'</directory>
 			<directory suffix=".php">'../../system/core/CodeIgniter.php'</directory>
 		</blacklist>
-		<whitelist>
-			<!--
-			<directory suffix=".php">'../system/core'</directory>
-			-->
-		</whitelist>
 	</filters>
 </phpunit>
\ No newline at end of file
diff --git a/tests/travis/sqlite.phpunit.xml b/tests/travis/sqlite.phpunit.xml
index 74ebb48..628370e 100644
--- a/tests/travis/sqlite.phpunit.xml
+++ b/tests/travis/sqlite.phpunit.xml
@@ -28,10 +28,5 @@
 			<directory suffix=".php">PROJECT_BASE.'tests'</directory>
 			<directory suffix=".php">'../../system/core/CodeIgniter.php'</directory>
 		</blacklist>
-		<whitelist>
-			<!--
-			<directory suffix=".php">'../system/core'</directory>
-			-->
-		</whitelist>
 	</filters>
 </phpunit>
\ No newline at end of file
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 5f6d591..03a020a 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -29,6 +29,7 @@
    -  Added support for 3gp, 3g2, mp4, wmv, f4v, vlc Video files to mimes.php.
    -  Added support for m4a, aac, m4u, xspf, au, ac3, flac, ogg Audio files to mimes.php.
    -  Added support for kmz and kml (Google Earth) files to mimes.php.
+   -  Added Romanian and Greek characters in foreign_characters.php
    -  Updated support for doc files in mimes.php.
    -  Added application/xml for xml and application/xml, text/xsl for xsl in mimes.php.
    -  Changed logger to only chmod when file is first created.
@@ -54,7 +55,11 @@
 
 -  Database
 
-   -  Added new :doc:`Active Record <database/active_record>` methods that return
+   -  Renamed the Active Record class to Query Builder to remove confusion with 
+      the Active Record design pattern
+   -  Added new :doc:`Query Builder <database/query_builder>` methods that return
+   -  Added the ability to insert objects with insert_batch() in :doc:`Query Builder <database/query_builder>`.
+   -  Added new :doc:`Query Builder <database/query_builder>` methods that return
       the SQL string of queries without executing them: get_compiled_select(),
       get_compiled_insert(), get_compiled_update(), get_compiled_delete().
    -  Adding $escape parameter to the order_by function, this enables ordering by custom fields.
@@ -196,9 +201,10 @@
 -  Fixed a bug in the library loader where some PHP versions wouldn't execute the class constructor.
 -  Fixed a bug (#88) - An unexisting property was used for configuration of the Memcache cache driver.
 -  Fixed a bug (#14) - create_database() method in the :doc:`Database Forge Library <database/forge>` didn't utilize the configured database character set.
--  Fixed a bug (#1238) - delete_all() in the `Database Caching Library <database/caching>` used to delete .htaccess and index.html files, which is a potential security risk.
+-  Fixed a bug (#23, #1238) - delete_all() in the `Database Caching Library <database/caching>` used to delete .htaccess and index.html files, which is a potential security risk.
 -  Fixed a bug in :doc:`Trackback Library <libraries/trackback>` method validate_url() where it didn't actually do anything, due to input not being passed by reference.
 -  Fixed a bug (#11, #183, #863) - CI_Form_validation::_execute() silently continued to the next rule, if a rule method/function is not found.
+-  Fixed a bug (#122) Where routed uri string was being reported incorrectly in sub-directories
 -  Fixed a bug (#1242) - read_dir() in the :doc:`Zip Library <libraries/zip>` wasn't compatible with Windows.
 -  Fixed a bug (#306) - ODBC driver didn't have an _insert_batch() method, which resulted in fatal error being triggered when insert_batch() is used with it.
 -  Fixed a bug in MSSQL and SQLSrv's _truncate() where the TABLE keyword was missing.
@@ -206,6 +212,7 @@
 -  Fixed a bug (#798) - update() used to ignore LIKE conditions that were set with like().
 -  Fixed a bug in Oracle's and MSSQL's delete() methods where an erroneous SQL statement was generated when used with limit().
 -  Fixed a bug in SQLSRV's delete() method where like() and limit() conditions were ignored.
+-  Fixed a bug (#1265) - Database connections were always closed, regardless of the 'pconnect' option value.
 
 Version 2.1.1
 =============
diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst
index 3f3bae3..7a19c84 100644
--- a/user_guide_src/source/database/configuration.rst
+++ b/user_guide_src/source/database/configuration.rst
@@ -106,18 +106,18 @@
 default we've used the word "default" for the primary connection, but it
 too can be renamed to something more relevant to your project.
 
-Active Record
+Query Builder
 -------------
 
-The :doc:`Active Record Class <active_record>` is globally enabled or
-disabled by setting the $active_record variable in the database
+The :doc:`Query Builder Class <query_builder>` is globally enabled or
+disabled by setting the $query_builder variable in the database
 configuration file to TRUE/FALSE (boolean). If you are not using the
-active record class, setting it to FALSE will utilize fewer resources
+query builder class, setting it to FALSE will utilize fewer resources
 when the database classes are initialized.
 
 ::
 
-	$active_record = TRUE;
+	$query_builder = TRUE;
 
 .. note:: that some CodeIgniter classes such as Sessions require Active
 	Records be enabled to access certain functionality.
@@ -134,7 +134,7 @@
 **database**		The name of the database you want to connect to.
 **dbdriver**		The database type. ie: mysql, postgre, odbc, etc. Must be specified in lower case.
 **dbprefix**		An optional table prefix which will added to the table name when running :doc:
-			`Active Record <active_record>` queries. This permits multiple CodeIgniter installations
+			`Query Builder <query_builder>` queries. This permits multiple CodeIgniter installations
 			to share one database.
 **pconnect**		TRUE/FALSE (boolean) - Whether to use a persistent connection.
 **db_debug**		TRUE/FALSE (boolean) - Whether database errors should be displayed.
diff --git a/user_guide_src/source/database/connecting.rst b/user_guide_src/source/database/connecting.rst
index fb45241..5822ca6 100644
--- a/user_guide_src/source/database/connecting.rst
+++ b/user_guide_src/source/database/connecting.rst
@@ -36,7 +36,7 @@
    string.
 #. TRUE/FALSE (boolean). Whether to return the connection ID (see
    Connecting to Multiple Databases below).
-#. TRUE/FALSE (boolean). Whether to enable the Active Record class. Set
+#. TRUE/FALSE (boolean). Whether to enable the Query Builder class. Set
    to TRUE by default.
 
 Manually Connecting to a Database
diff --git a/user_guide_src/source/database/examples.rst b/user_guide_src/source/database/examples.rst
index d1cd488..8b3cc47 100644
--- a/user_guide_src/source/database/examples.rst
+++ b/user_guide_src/source/database/examples.rst
@@ -104,10 +104,10 @@
 	$this->db->query($sql);
 	echo $this->db->affected_rows();
 
-Active Record Query
+Query Builder Query
 ===================
 
-The :doc:`Active Record Pattern <active_record>` gives you a simplified
+The :doc:`Query Builder Pattern <query_builder>` gives you a simplified
 means of retrieving data::
 
 	$query = $this->db->get('table_name');
@@ -118,10 +118,10 @@
 	}
 
 The above get() function retrieves all the results from the supplied
-table. The :doc:`Active Record <active_record>` class contains a full
+table. The :doc:`Query Builder <query_builder>` class contains a full
 compliment of functions for working with data.
 
-Active Record Insert
+Query Builder Insert
 ====================
 
 ::
diff --git a/user_guide_src/source/database/index.rst b/user_guide_src/source/database/index.rst
index ab12b7c..7ccb8fb 100644
--- a/user_guide_src/source/database/index.rst
+++ b/user_guide_src/source/database/index.rst
@@ -3,7 +3,7 @@
 ##################
 
 CodeIgniter comes with a full-featured and very fast abstracted database
-class that supports both traditional structures and Active Record
+class that supports both traditional structures and Query Builder
 patterns. The database functions offer clear, simple syntax.
 
 .. toctree::
@@ -15,7 +15,7 @@
 	Running Queries <queries>
 	Generating Query Results <results>
 	Query Helper Functions <helpers>
-	Active Record Class <active_record>
+	Query Builder Class <query_builder>
 	Transactions <transactions>
 	Table MetaData <table_data>
 	Field MetaData <fields>
diff --git a/user_guide_src/source/database/queries.rst b/user_guide_src/source/database/queries.rst
index 15a7361..d23efec 100644
--- a/user_guide_src/source/database/queries.rst
+++ b/user_guide_src/source/database/queries.rst
@@ -50,7 +50,7 @@
 **********************
 
 In many databases it is advisable to protect table and field names - for
-example with backticks in MySQL. **Active Record queries are
+example with backticks in MySQL. **Query Builder queries are
 automatically protected**, however if you need to manually protect an
 identifier you can use::
 
diff --git a/user_guide_src/source/database/active_record.rst b/user_guide_src/source/database/query_builder.rst
similarity index 95%
rename from user_guide_src/source/database/active_record.rst
rename to user_guide_src/source/database/query_builder.rst
index e328c11..54e8df6 100644
--- a/user_guide_src/source/database/active_record.rst
+++ b/user_guide_src/source/database/query_builder.rst
@@ -1,15 +1,15 @@
 ###################
-Active Record Class
+Query Builder Class
 ###################
 
-CodeIgniter uses a modified version of the Active Record Database
-Pattern. This pattern allows information to be retrieved, inserted, and
-updated in your database with minimal scripting. In some cases only one
-or two lines of code are necessary to perform a database action.
+CodeIgniter gives you access to a Query Builder class. This pattern 
+allows information to be retrieved, inserted, and updated in your 
+database with minimal scripting. In some cases only one or two lines
+of code are necessary to perform a database action.
 CodeIgniter does not require that each database table be its own class
 file. It instead provides a more simplified interface.
 
-Beyond simplicity, a major benefit to using the Active Record features
+Beyond simplicity, a major benefit to using the Query Builder features
 is that it allows you to create database independent applications, since
 the query syntax is generated by each database adapter. It also allows
 for safer queries, since the values are escaped automatically by the
@@ -67,8 +67,8 @@
 
 	// Produces string: SELECT * FROM mytable
 
-The second parameter enables you to set whether or not the active record query
-will be reset (by default it will be just like `$this->db->get()`)::
+The second parameter enables you to set whether or not the query builder query
+will be reset (by default it will be&mdash;just like `$this->db->get()`)::
 
 	echo $this->db->limit(10,20)->get_compiled_select('mytable', FALSE);
 	// Produces string: SELECT * FROM mytable LIMIT 20, 10
@@ -512,7 +512,7 @@
 ==============================
 
 Permits you to determine the number of rows in a particular Active
-Record query. Queries will accept Active Record restrictors such as
+Record query. Queries will accept Query Builder restrictors such as
 where(), or_where(), like(), or_like(), etc. Example::
 
 	echo $this->db->count_all_results('my_table');  // Produces an integer, like 25
@@ -636,7 +636,7 @@
 
 	// Produces string: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date')
 
-The second parameter enables you to set whether or not the active record query
+The second parameter enables you to set whether or not the query builder query
 will be reset (by default it will be--just like `$this->db->insert()`_)::
 
 	echo $this->db->set('title', 'My Title')->get_compiled_insert('mytable', FALSE);
@@ -928,12 +928,12 @@
 .. _ar-caching:
 
 *********************
-Active Record Caching
+Query Builder Caching
 *********************
 
-While not "true" caching, Active Record enables you to save (or "cache")
+While not "true" caching, Query Builder enables you to save (or "cache")
 certain parts of your queries for reuse at a later point in your
-script's execution. Normally, when an Active Record call is completed,
+script's execution. Normally, when an Query Builder call is completed,
 all stored information is reset for the next call. With caching, you can
 prevent this reset, and reuse information easily.
 
@@ -944,7 +944,7 @@
 $this->db->start_cache()
 ========================
 
-This function must be called to begin caching. All Active Record queries
+This function must be called to begin caching. All Query Builder queries
 of the correct type (see below for supported queries) are stored for
 later use.
 
@@ -956,7 +956,7 @@
 $this->db->flush_cache()
 ========================
 
-This function deletes all items from the Active Record cache.
+This function deletes all items from the Query Builder cache.
 
 Here's a usage example::
 
@@ -983,12 +983,12 @@
 $this->db->reset_query()
 ========================
 
-Resetting Active Record allows you to start fresh with your query without
+Resetting Query Builder allows you to start fresh with your query without
 executing it first using a method like $this->db->get() or $this->db->insert().
 Just like the methods that execute a query, this will *not* reset items you've
-cached using `Active Record Caching`_.
+cached using `Query Builder Caching`_.
 
-This is useful in situations where you are using Active Record to generate SQL
+This is useful in situations where you are using Query Builder to generate SQL
 (ex. ``$this->db->get_compiled_select()``) but then choose to, for instance,
 run the query::
 
diff --git a/user_guide_src/source/general/models.rst b/user_guide_src/source/general/models.rst
index b816f95..0156b04 100644
--- a/user_guide_src/source/general/models.rst
+++ b/user_guide_src/source/general/models.rst
@@ -55,7 +55,7 @@
 	}
 
 .. note:: The functions in the above example use the :doc:`Active
-	Record <../database/active_record>` database functions.
+	Record <../database/query_builder>` database functions.
 
 .. note:: For the sake of simplicity in this example we're using $_POST
 	directly. This is generally bad practice, and a more common approach
diff --git a/user_guide_src/source/helpers/directory_helper.rst b/user_guide_src/source/helpers/directory_helper.rst
index fd16988..cf88732 100644
--- a/user_guide_src/source/helpers/directory_helper.rst
+++ b/user_guide_src/source/helpers/directory_helper.rst
@@ -59,7 +59,7 @@
 				[1] => config.html        
 				[database] => Array
 					(              
-						[0] => active_record.html              
+						[0] => query_builder.html              
 						[1] => binds.html              
 						[2] => configuration.html
 						[3] => connecting.html              
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index 4c594ab..e434e8d 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -31,3 +31,13 @@
 
 Use of the `$autoload['core']` config array has been deprecated as of CodeIgniter 1.4.1 and is now removed.
 Move any entries that you might have listed there to `$autoload['libraries']` instead.
+
+Step 4: Update your config/database.php
+=======================================
+
+Due to 3.0.0's renaming of Active Record to Query Builder, inside your _config/database.php_, you will
+need to rename the `$active_record` variable to `$query_builder`.
+
+    $active_group = 'default';
+    // $active_record = TRUE;
+    $query_builder = TRUE;
\ No newline at end of file
diff --git a/user_guide_src/source/libraries/javascript.rst b/user_guide_src/source/libraries/javascript.rst
index 5e80fb9..d5e09c3 100644
--- a/user_guide_src/source/libraries/javascript.rst
+++ b/user_guide_src/source/libraries/javascript.rst
@@ -86,14 +86,14 @@
 To initialize the jQuery class manually in your controller constructor,
 use the $this->load->library function::
 
-	$this->load->library('jquery');
+	$this->load->library('javascript/jquery');
 
 You may send an optional parameter to determine whether or not a script
 tag for the main jQuery file will be automatically included when loading
 the library. It will be created by default. To prevent this, load the
 library as follows::
 
-	$this->load->library('jquery', FALSE);
+	$this->load->library('javascript/jquery', FALSE);
 
 Once loaded, the jQuery library object will be available using:
 $this->jquery
diff --git a/user_guide_src/source/overview/features.rst b/user_guide_src/source/overview/features.rst
index 44db08a..8c27b14 100644
--- a/user_guide_src/source/overview/features.rst
+++ b/user_guide_src/source/overview/features.rst
@@ -15,7 +15,7 @@
 -  Model-View-Controller Based System
 -  Extremely Light Weight
 -  Full Featured database classes with support for several platforms.
--  Active Record Database Support
+-  Query Builder Database Support
 -  Form and Data Validation
 -  Security and XSS Filtering
 -  Session Management
diff --git a/user_guide_src/source/tutorial/create_news_items.rst b/user_guide_src/source/tutorial/create_news_items.rst
index 794b67e..bfaf135 100644
--- a/user_guide_src/source/tutorial/create_news_items.rst
+++ b/user_guide_src/source/tutorial/create_news_items.rst
@@ -94,7 +94,7 @@
 -----
 
 The only thing that remains is writing a method that writes the data to
-the database. You'll use the Active Record class to insert the
+the database. You'll use the Query Builder class to insert the
 information and use the input library to get the posted data. Open up
 the model created earlier and add the following:
 
diff --git a/user_guide_src/source/tutorial/index.rst b/user_guide_src/source/tutorial/index.rst
index c959d04..b1ab331 100644
--- a/user_guide_src/source/tutorial/index.rst
+++ b/user_guide_src/source/tutorial/index.rst
@@ -16,7 +16,7 @@
 -  Model-View-Controller basics
 -  Routing basics
 -  Form validation
--  Performing basic database queries using "Active Record"
+-  Performing basic database queries using "Query Builder"
 
 The entire tutorial is split up over several pages, each explaining a
 small part of the functionality of the CodeIgniter framework. You'll go
diff --git a/user_guide_src/source/tutorial/news_section.rst b/user_guide_src/source/tutorial/news_section.rst
index 38e4214..82b3e3b 100644
--- a/user_guide_src/source/tutorial/news_section.rst
+++ b/user_guide_src/source/tutorial/news_section.rst
@@ -54,7 +54,7 @@
 Now that the database and a model have been set up, you'll need a method
 to get all of our posts from our database. To do this, the database
 abstraction layer that is included with CodeIgniter — `Active
-Record <../database/active_record.html>`_ — is used. This makes it
+Record <../database/query_builder.html>`_ — is used. This makes it
 possible to write your 'queries' once and make them work on `all
 supported database systems <../general/requirements.html>`_. Add the
 following code to your model.
@@ -76,7 +76,7 @@
 With this code you can perform two different queries. You can get all
 news records, or get a news item by its `slug <#>`_. You might have
 noticed that the $slug variable wasn't sanitized before running the
-query; Active Record does this for you.
+query; Query Builder does this for you.
 
 Display the news
 ----------------