diff --git a/classes/db/DbMySQLi.php b/classes/db/DbMySQLi.php index aed30ef9a..278f55ea2 100644 --- a/classes/db/DbMySQLi.php +++ b/classes/db/DbMySQLi.php @@ -35,7 +35,13 @@ class DbMySQLiCore extends Db */ public function connect() { - $this->link = @new mysqli($this->server, $this->user, $this->password, $this->database); + if (strpos($this->server, ':') !== false) + { + list($server, $port) = explode(':', $this->server); + $this->link = @new mysqli($server, $this->user, $this->password, $this->database, $port); + } + else + $this->link = @new mysqli($this->server, $this->user, $this->password, $this->database); // Do not use object way for error because this work bad before PHP 5.2.9 if (mysqli_connect_error()) diff --git a/classes/db/DbPDO.php b/classes/db/DbPDO.php index 640ff5894..40d0851da 100644 --- a/classes/db/DbPDO.php +++ b/classes/db/DbPDO.php @@ -39,7 +39,16 @@ class DbPDOCore extends Db { try { - $this->link = new PDO('mysql:dbname='.$this->database.';host='.$this->server, $this->user, $this->password); + $dsn = 'mysql:dbname='.$this->database; + if (strpos($this->server, ':') !== false) + { + list($server, $port) = explode(':', $this->server); + $dsn .= ';server='.$server.';port='.$port; + } + else + $dsn .= ';server='.$this->server; + + $this->link = new PDO($dsn, $this->user, $this->password); } catch (PDOException $e) {