// Add support of different mysql port for mysqli and pdo

This commit is contained in:
rMalie
2012-02-02 13:50:27 +00:00
parent 5072195fbc
commit ec039bc37f
2 changed files with 17 additions and 2 deletions
+10 -1
View File
@@ -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)
{