溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

php連接postgresql的方法

發布時間:2020-07-15 15:57:32 來源:億速云 閱讀:350 作者:清晨 欄目:編程語言

這篇文章主要介紹php連接postgresql的方法,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

PHP中可以使用pg_connect函數連接postgresql數據庫。

pg_connect() 打開一個由 connection_string 所指定的 PostgreSQL 數據庫的連接。如果成功則返回連接資源,如果不能連接則返回 FALSE。connection_string 應該是用引號引起來的字符串。

語法:

pg_connect ( string $connection_string ) : resource

pg_connect() 返回其它 PostgreSQL 函數所需要的資源。

pg_connect() 打開一個由 connection_string 所指定的 PostgreSQL 數據庫的連接。如果成功則返回連接資源,如果不能連接則返回 FALSE。connection_string 應該是用引號引起來的字符串。

示例:

<?php
$dbconn = pg_connect("dbname=mary");
//connect to a database named "mary"
$dbconn2 = pg_connect("host=localhost port=5432 dbname=mary");
// connect to a database named "mary" on "localhost" at port "5432"
$dbconn3 = pg_connect("host=sheep port=5432 dbname=mary user=lamb password=foo");
//connect to a database named "mary" on the host "sheep" with a username and password

$conn_string = "host=sheep port=5432 dbname=test user=lamb password=bar";
$dbconn4 = pg_connect($conn_string);
//connect to a database named "test" on the host "sheep" with a username and password
?>

以上是php連接postgresql的方法的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女