本文介紹了如何讓 php 與 postgresql 一起工作?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
<?php
try {
$dbh = new PDO('pgsql:host=localhost;port=5432;dbname=###;user=###;password=##');
echo "PDO connection object created";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>
我收到錯誤消息無法加載驅動程序"
I get the error message "Could Not Load Driver"
推薦答案
試試這個:
在 php.ini 中通過刪除;"取消注釋以下內容
Uncomment the following in php.ini by removing the ";"
;extension=php_pgsql.dll
使用以下代碼連接到 postgresql 數據庫服務器:
Use the following code to connect to a postgresql database server:
pg_connect("host=localhost dbname=dbname user=username password=password")
or die("Can't connect to database".pg_last_error());
這篇關于如何讓 php 與 postgresql 一起工作?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!