創(chuàng)新互聯(lián)www.cdcxhl.cn八線動(dòng)態(tài)BGP香港云服務(wù)器提供商,新人活動(dòng)買多久送多久,劃算不套路!
這篇文章主要介紹php連接postgresql的方法,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
PHP中可以使用pg_connect函數(shù)連接postgresql數(shù)據(jù)庫。
pg_connect() 打開一個(gè)由 connection_string 所指定的 PostgreSQL 數(shù)據(jù)庫的連接。如果成功則返回連接資源,如果不能連接則返回 FALSE。connection_string 應(yīng)該是用引號(hào)引起來的字符串。
語法:
pg_connect ( string $connection_string ) : resource
pg_connect() 返回其它 PostgreSQL 函數(shù)所需要的資源。
pg_connect() 打開一個(gè)由 connection_string 所指定的 PostgreSQL 數(shù)據(jù)庫的連接。如果成功則返回連接資源,如果不能連接則返回 FALSE。connection_string 應(yīng)該是用引號(hào)引起來的字符串。
示例:
<?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的方法的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道!
本文名稱:php連接postgresql的方法-創(chuàng)新互聯(lián)
文章地址:http://chinadenli.net/article2/dhpgoc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、品牌網(wǎng)站制作、動(dòng)態(tài)網(wǎng)站、響應(yīng)式網(wǎng)站、網(wǎng)站內(nèi)鏈、靜態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容