From a2ac7a6cc69228b959a1bf3f79acd649d0059110 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 8 Apr 2006 17:34:04 +0000 Subject: [PATCH] - fix for a php bug (not able to connect on custom ports if the server is localhost - though 127.0.0.1 works) -> #1444 git-svn-id: file:///svn/phpbb/trunk@5774 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/mysqli.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index 3b0abe8e81..137ca39591 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -39,10 +39,12 @@ class dbal_mysqli extends dbal { $this->persistency = $persistency; $this->user = $sqluser; - $this->server = $sqlserver . (($port) ? ':' . $port : ''); + $this->server = $sqlserver; $this->dbname = $database; + $port = (!$port) ? NULL : $port; - $this->db_connect_id = ($this->persistency) ? @mysqli_pconnect($this->server, $this->user, $sqlpassword) : @mysqli_connect($this->server, $this->user, $sqlpassword); + // 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 != '') { @@ -289,6 +291,14 @@ class dbal_mysqli extends dbal */ function _sql_error() { + if (!$this->db_connect_id) + { + return array( + 'message' => @mysqli_connect_error(), + 'code' => @mysqli_connect_errno() + ); + } + return array( 'message' => @mysqli_error($this->db_connect_id), 'code' => @mysqli_errno($this->db_connect_id)