aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db/mysqli.php
diff options
context:
space:
mode:
authorrxu <rxu@mail.ru>2011-06-19 19:03:53 +0800
committerrxu <rxu@mail.ru>2011-06-19 19:03:53 +0800
commit7de078b26e2a0b2672f24efe715b440cca7f5979 (patch)
tree59853b1519c9d64c5e06e8255e3c191d5d6b99bf /phpBB/includes/db/mysqli.php
parent4ac9bde2d121276a12b784ab7c56b7f5a4b6c77e (diff)
downloadforums-7de078b26e2a0b2672f24efe715b440cca7f5979.tar
forums-7de078b26e2a0b2672f24efe715b440cca7f5979.tar.gz
forums-7de078b26e2a0b2672f24efe715b440cca7f5979.tar.bz2
forums-7de078b26e2a0b2672f24efe715b440cca7f5979.tar.xz
forums-7de078b26e2a0b2672f24efe715b440cca7f5979.zip
[ticket/10227] Allow persistent connections for mysqli with PHP 5.3.0+
PHPBB3-10227
Diffstat (limited to 'phpBB/includes/db/mysqli.php')
-rw-r--r--phpBB/includes/db/mysqli.php9
1 files changed, 6 insertions, 3 deletions
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index 862d62f4ba..dcf8727e18 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -33,13 +33,16 @@ class dbal_mysqli extends dbal
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false , $new_link = false)
{
- $this->persistency = $persistency;
+ // Mysqli extension supports persistent connection since PHP 5.3.0
+ $this->persistency = (version_compare(PHP_VERSION, '5.3.0', '>=')) ? $persistency : false;
$this->user = $sqluser;
- $this->server = $sqlserver;
+
+ // If persistent connection, set dbhost to localhost when empty and prepend it with 'p:' prefix
+ $this->server = ($this->persistency) ? 'p:' . (($sqlserver) ? $sqlserver : 'localhost') : $sqlserver;
+
$this->dbname = $database;
$port = (!$port) ? NULL : $port;
- // Persistant connections not supported by the mysqli extension?
$this->db_connect_id = @mysqli_connect($this->server, $this->user, $sqlpassword, $this->dbname, $port);
if ($this->db_connect_id && $this->dbname != '')