如何在 Linux 中 Php (windowns 7) 连接 PostgreSQL


How to Php (windowns 7) connect PostgreSQL in linux

我想在 Linux 中使用 php 在 Windows 中连接到 PostgreSQL。

致命错误:调用未定义的函数 pg_connect((

谢谢。

PDO更倾向于connet数据库。为此,您需要为pg_sql启用 PDO。请更改 php.ini 文件以进行pg_sql。

$hostname = "localhost";
$database = "postsgres";
$username = "postgres";
$password = "postgres";
try{
    $dbh = new PDO("pgsql:dbname=$database;host=$hostname",$username,$password);
} catch (Exception $ex) {
    echo $ex->getMessage();
}