aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db/mysqli.php
diff options
context:
space:
mode:
authorrxu <rxu@mail.ru>2011-06-21 00:21:42 +0800
committerrxu <rxu@mail.ru>2011-06-21 00:55:10 +0800
commit578f9dffa607de1da2aa181b49be583f27f3bf28 (patch)
tree1bb1f68bf02384c599b691a58aaf8941d7b70e57 /phpBB/includes/db/mysqli.php
parentfd7e29131ecf437823f625e60e8bbcc0ddb0de40 (diff)
downloadforums-578f9dffa607de1da2aa181b49be583f27f3bf28.tar
forums-578f9dffa607de1da2aa181b49be583f27f3bf28.tar.gz
forums-578f9dffa607de1da2aa181b49be583f27f3bf28.tar.bz2
forums-578f9dffa607de1da2aa181b49be583f27f3bf28.tar.xz
forums-578f9dffa607de1da2aa181b49be583f27f3bf28.zip
[ticket/10226] Allow mysqli connections via local sockets/pipes
PHPBB3-10226
Diffstat (limited to 'phpBB/includes/db/mysqli.php')
-rw-r--r--phpBB/includes/db/mysqli.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index dcf8727e18..1901847c0f 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -43,7 +43,23 @@ class dbal_mysqli extends dbal
$this->dbname = $database;
$port = (!$port) ? NULL : $port;
- $this->db_connect_id = @mysqli_connect($this->server, $this->user, $sqlpassword, $this->dbname, $port);
+ // If port is set and it is not numeric, most likely mysqli socket is set.
+ // Try to map it to the $socket parameter.
+ $socket = NULL;
+ if ($port)
+ {
+ if (preg_match('#^[0-9]+$#', $port))
+ {
+ $port = (int) $port;
+ }
+ else
+ {
+ $socket = $port;
+ $port = NULL;
+ }
+ }
+
+ $this->db_connect_id = @mysqli_connect($this->server, $this->user, $sqlpassword, $this->dbname, $port, $socket);
if ($this->db_connect_id && $this->dbname != '')
{