您现在的位置是:课程教程文章
php如何连接postgresql
2023-12-18 19:10课程教程文章 人已围观
-
GraphPad Prism统计绘图教程(持续更新SPSS统
GraphPad Prism统计绘图教程(持续更新SPSS统为什么我们的《GraphPad+SPSS统计绘图教程》要持续更新课程? 1.因为GraphPad Pris... -
php/tp6/laravel短信接口/api调试/接口优化/微
php/tp6/laravel短信接口/api调试/接口优化/微... -
PostgreSQL Certified Associate(初级)自助学习
PostgreSQL Certified Associate(初级)自助学习... -
微信支付v3版php_申请交易账单+申请资金账
微信支付v3版php_申请交易账单+申请资金账微信支付V3版系列课程详细讲解微信支付的 JSAPI支付 、 H5支付 、 Native支付 、...
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 ?>
推荐:PostgreSQL教程
课程教程:php如何连接postgresql下一篇:没有了