Set MySQL client compression to FALSE by default (problems reported with it), fix some typos, add encrypted database connections support and fix SQLSRV CharacterSet setting
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 7262591..336db97 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -41,6 +41,7 @@
 class CI_DB_mysql_driver extends CI_DB {
 
 	public $dbdriver = 'mysql';
+	public $compress = FALSE;
 
 	// The character used for escaping
 	protected $_escape_char = '`';
@@ -75,18 +76,20 @@
 	/**
 	 * Non-persistent database connection
 	 *
+	 * @param	bool
 	 * @return	resource
 	 */
-	public function db_connect()
+	public function db_connect($persistent = FALSE)
 	{
-		if ($this->compress === TRUE)
+		$connect_func = ($persistent === TRUE) ? 'mysql_pconnect' : 'mysql_connect';
+		$client_flags = ($this->compress === FALSE) ? 0 : MYSQL_CLIENT_COMPRESS;
+
+		if ($this->encrypt === TRUE)
 		{
-			return @mysql_connect($this->hostname, $this->username, $this->password, TRUE, MYSQL_CLIENT_COMPRESS);
+			$client_flags = $client_flags | MYSQL_CLIENT_SSL;
 		}
-		else
-		{
-			return @mysql_connect($this->hostname, $this->username, $this->password, TRUE);
-		}
+
+		return @$connect_func($this->hostname, $this->username, $this->password, TRUE, $client_flags);
 	}
 
 	// --------------------------------------------------------------------
@@ -98,14 +101,7 @@
 	 */
 	public function db_pconnect()
 	{
-		if ($this->compress === TRUE)
-		{
-			return @mysql_pconnect($this->hostname, $this->username, $this->password, MYSQL_CLIENT_COMPRESS);
-		}
-		else
-		{
-			return @mysql_pconnect($this->hostname, $this->username, $this->password);
-		}
+		return $this->db_connect(TRUE);
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index b5a1e26..f77176c 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -41,6 +41,7 @@
 class CI_DB_mysqli_driver extends CI_DB {
 
 	public $dbdriver = 'mysqli';
+	public $compress = FALSE;
 
 	// The character used for escaping
 	protected $_escape_char = '`';
@@ -57,24 +58,21 @@
 	/**
 	 * Non-persistent database connection
 	 *
+	 * @param	bool
 	 * @return	object
+	 * @todo	SSL support
 	 */
-	public function db_connect()
+	public function db_connect($persistent = FALSE)
 	{
-		// Use MySQL client compression?
-		if ($this->compress === TRUE)
-		{
-			$port = empty($this->port) ? NULL : $this->port;
+		// Persistent connection support was added in PHP 5.3.0
+		$hostname = ($persistent === TRUE && is_php('5.3'))
+			? 'p:'.$this->hostname : $this->hostname;
+		$port = empty($this->port) ? NULL : $this->port;
+		$client_flags = ($this->compress === TRUE) ? MYSQLI_CLIENT_COMPRESS : 0;
+		$mysqli = new mysqli();
 
-			$mysqli = new mysqli();
-			@$mysqli->real_connect($this->hostname, $this->username, $this->password, $this->database, $port, NULL, MYSQLI_CLIENT_COMPRESS);
-
-			return $mysqli;
-		}
-
-		return empty($this->port)
-			? @new mysqli($this->hostname, $this->username, $this->password, $this->database)
-			: @new mysqli($this->hostname, $this->username, $this->password, $this->database, $this->port);
+		return @$mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, NULL, $client_flags)
+			? $mysqli : FALSE;
 	}
 
 	// --------------------------------------------------------------------
@@ -86,26 +84,7 @@
 	 */
 	public function db_pconnect()
 	{
-		// Persistent connection support was added in PHP 5.3.0
-		if ( ! is_php('5.3'))
-		{
-			return $this->db_connect();
-		}
-
-		// Use MySQL client compression?
-		if ($this->compress === TRUE)
-		{
-			$port = empty($this->port) ? NULL : $this->port;
-
-			$mysqli = mysqli_init();
-			$mysqli->real_connect('p:'.$this->hostname, $this->username, $this->password, $this->database, $port, NULL, MYSQLI_CLIENT_COMPRESS);
-
-			return $mysqli;
-		}
-
-		return empty($this->port)
-			? @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database)
-			: @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database, $this->port);
+		return $this->db_connect(TRUE);
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
index 4244688..a543117 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
@@ -41,6 +41,7 @@
 class CI_DB_pdo_mysql_driver extends CI_DB_pdo_driver {
 
 	public $subdriver = 'mysql';
+	public $compress = FALSE;
 
 	protected $_escape_char = '`';
 
@@ -79,6 +80,7 @@
 	 *
 	 * @param	bool
 	 * @return	object
+	 * @todo	SSL support
 	 */
 	public function db_connect($persistent = FALSE)
 	{
@@ -93,6 +95,11 @@
 				.(empty($this->dbcollat) ? '' : ' COLLATE '.$this->dbcollat);
 		}
 
+		if ($this->compress === TRUE)
+		{
+			$this->options[PDO::MYSQL_ATTR_COMPRESS] = TRUE;
+		}
+
 		return parent::db_connect($persistent);
 	}
 
diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
index fd1c4b2..3154fdd 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
@@ -78,9 +78,9 @@
 				$this->dsn .= ';ConnectionPooling='.$this->ConnectionPooling;
 			}
 
-			if (isset($this->Encrypt))
+			if ($this->encrypt === TRUE)
 			{
-				$this->dsn .= ';Encrypt='.$this->Encrypt;
+				$this->dsn .= ';Encrypt=1';
 			}
 
 			if (isset($this->TraceOn))
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 3ffbd4c..be321ff 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -57,15 +57,16 @@
 	 */
 	public function db_connect($pooling = FALSE)
 	{
-		// Check for a UTF-8 charset being passed as CI's default 'utf8'.
-		$character_set = (0 === strcasecmp('utf8', $this->char_set)) ? 'UTF-8' : $this->char_set;
+		$charset = in_array(strtolower($this->char_set), array('utf-8', 'utf8'), TRUE)
+			? 'UTF-8' : SQLSRV_ENC_CHAR;
 
 		$connection = array(
 			'UID'			=> empty($this->username) ? '' : $this->username,
 			'PWD'			=> empty($this->password) ? '' : $this->password,
 			'Database'		=> $this->database,
-			'ConnectionPooling'	=> $pooling ? 1 : 0,
-			'CharacterSet'		=> $character_set,
+			'ConnectionPooling'	=> ($pooling === TRUE) ? 1 : 0,
+			'CharacterSet'		=> $charset,
+			'Encrypt'		=> ($this->encrypt === TRUE) ? 1 : 0,
 			'ReturnDatesAsStrings'	=> 1
 		);