Fix host options

master
Vitaliy Filippov 2018-10-21 15:36:25 +03:00
parent 0042f199e7
commit bcd5521cea
1 changed files with 3 additions and 3 deletions

View File

@ -3,7 +3,7 @@
/**
* PDO/PostgreSQL wrapper with (mostly) DatabaseMySQL interface :)
* Select builder is inspired by MediaWiki's one.
* Version: 2018-10-09
* Version: 2018-10-21
* (c) Vitaliy Filippov, 2015-2018
*/
@ -87,7 +87,7 @@ class DatabasePdoPgsql implements Database
'init' => array(),
);
$options += $defOpts;
if ($options['socket'])
if ($options['socket'] && !$options['host'])
{
$options['host'] = 'localhost';
}
@ -110,7 +110,7 @@ class DatabasePdoPgsql implements Database
function connect()
{
$str = "pgsql:port=".intval($this->port);
$str .= ";host='".($this->socket !== NULL ? $this->socket : $this->host)."';dbname='".$this->dbname."'";
$str .= ";host='".($this->host == 'localhost' && $this->socket !== NULL ? $this->socket : $this->host)."';dbname='".$this->dbname."'";
try
{
$this->link = new PDO($str, $this->username, $this->password, array(