summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/mysqli/mysqli_driver.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-10-12 19:51:39 +0200
committerAndrey Andreev <narf@bofh.bg>2012-10-12 19:51:39 +0200
commitf83c4363b5459d294255e3817a230258861ec79b (patch)
treee88929ac21246cab365d865ccc82aed56663a414 /system/database/drivers/mysqli/mysqli_driver.php
parenta23e10fd2369cc85c4b942c5de6a8cf05a5b2b67 (diff)
parent98ebf4351f8aad58504cd7318ddd94faf0dec482 (diff)
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into feature/db_qb_aliasing
Diffstat (limited to 'system/database/drivers/mysqli/mysqli_driver.php')
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php49
1 files changed, 14 insertions, 35 deletions
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 934694c6c..0a454da6c 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 @@ class CI_DB_mysqli_driver extends CI_DB {
/**
* 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;
-
- $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);
+ // 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();
+
+ return @$mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, NULL, $client_flags)
+ ? $mysqli : FALSE;
}
// --------------------------------------------------------------------
@@ -86,26 +84,7 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
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);
}
// --------------------------------------------------------------------