我只是无法让它工作,我总是得到:连接到 PGSQL 数据库时出错。
我安装并运行了 PGSQL 数据库,并安装了通过 PostgreSQL 安装的 php 服务器。任何帮助表示赞赏。
我只是无法让它工作,我总是得到:连接到 PGSQL 数据库时出错。
我安装并运行了 PGSQL 数据库,并安装了通过 PostgreSQL 安装的 php 服务器。任何帮助表示赞赏。
我遇到了这个在同一问题上寻求帮助的答案,而我得到的最远的答案是在这个答案Error connection to PGSQL database in Joomla的帮助下。此后,我打开 Joomla 核心并确定他们没有在他们的 postgresql 驱动程序中容纳主机:端口拆分。
因此,破解 INSTALL_PATH/libraries/joomla/database/driver/postgresql.php 第 126 行,并通过将 if 子句更改为下面粘贴的内容来容纳端口信息,帮助我连接。
if (!empty($this->options['host']))
{
if(strpos($this->options['host'] ,":" )!== false){
$host_p = explode(':' , $this->options['host']);
if(count($host_p) == 2){
$host = $host_p[0];
$port = $host_p[1];
$dsn .= "host={$host} port={$port} ";
}else{
$dsn .= "host={$this->options['host']} ";
}
}
else{
$dsn .= "host={$this->options['host']} ";
}
}
$dsn .= "dbname={$this->options['database']} user={$this->options['user']} password={$this->options['password']}";//left as is