简体   繁体   English

pg_connect不适用于PHP 5

[英]pg_connect not working with PHP 5

I'm working on an application that runs fine with PHP 4 in a windows 8 server. 我正在开发在Windows 8服务器中与PHP 4一起运行良好的应用程序。 I'm setting a local server with postgres to work locally but with PHP 5 to migrate a few things. 我正在使用postgres设置本地服务器以在本地工作,但是使用PHP 5来迁移一些东西。 I'm having some compatibility issues but nothing big except that the pg_connect function in a class is not working and is not throwing me any error 我遇到一些兼容性问题,但没什么大不了,除了一个类中的pg_connect函数无法正常工作并且不会向我抛出任何错误

class basededatos{
    var $link_;

    function basededatos(){
        $this->link_=pg_connect("host=localhost port=5432 dbname=... user=postgres password=...") or die('Falla en la conexión a la Base de Datos. Por favor, Revise la Configuración.');
    }

    function cerrarconexion(){
        pg_close($this->link_);
    }

    function Abreconexionconretorno($consulta){
        $resultado=pg_query($consulta)or die("La consulta falló con error: ".pg_last_error());
        return $resultado;
    }

    function Abreconexionsinretorno($consulta){
        pg_query($consulta)or die("La consulta falló con error: ".pg_last_error());
    }
}

After this 在这之后

$this->link_=pg_connect(...)

It just dies, any idea why is this happenning? 它只是死了,你知道为什么会这样吗? Thanks 谢谢

Probably you don't have PostreSQL extension enabled in php.ini file because You upgraded to PHP 5. Just add this line to php.ini if pgsql module for PHP is installed: 可能是因为您已升级到PHP 5,所以您没有在php.ini文件中启用PostreSQL扩展。如果已安装PHP的pgsql模块,请将此行添加到php.ini中:

extension=php_pgsql.dll (windows) extension=php_pgsql.dll (Windows)

extension=php_pgsql.so (linux) extension=php_pgsql.so (Linux)

If the module is not installed then go with: 如果未安装模块,请继续执行以下操作:

sudo apt-get install php5-pgsql

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM