(PHP 4, PHP 5, PHP 7)
pg_connect — 锟斤拷一锟斤拷 PostgreSQL 锟斤拷锟斤拷
$connection_string
) : resourcepg_connect() 锟斤拷锟斤拷锟斤拷锟斤拷 PostgreSQL 锟斤拷锟斤拷锟斤拷锟斤拷要锟斤拷锟斤拷源锟斤拷
pg_connect() 锟斤拷一锟斤拷锟斤拷
connection_string
锟斤拷指锟斤拷锟斤拷
PostgreSQL 锟斤拷锟捷匡拷锟斤拷锟斤拷印锟斤拷锟斤拷锟缴癸拷锟津返伙拷锟斤拷锟斤拷锟斤拷源锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷蚍祷锟�
FALSE
锟斤拷connection_string
应锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷
Example #1 使锟斤拷 pg_connect()
<?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
?>
connection_string
锟斤拷锟斤拷锟斤拷锟侥诧拷锟斤拷锟斤拷
host
锟斤拷port
锟斤拷tty
, options
锟斤拷dbname
, user
锟斤拷 password
锟斤拷
锟斤拷锟斤拷锟酵拷锟斤拷锟� connection_string
锟劫次碉拷锟斤拷
pg_connect()锟斤拷锟斤拷锟结建锟斤拷锟斤拷锟斤拷锟接o拷锟斤拷锟角凤拷锟斤拷前锟斤拷锟窖撅拷锟津开碉拷锟斤拷锟斤拷锟斤拷源锟斤拷锟斤拷锟绞癸拷貌锟酵拷锟斤拷锟斤拷锟斤拷址锟斤拷锟斤拷锟斤拷锟斤拷锟皆猴拷同一锟斤拷锟斤拷锟捷库建锟斤拷锟斤拷锟斤拷锟斤拷印锟�
锟缴的讹拷锟斤拷锟斤拷锓� $conn = pg_connect("host", "port", "options", "tty", "dbname") 锟窖撅拷锟斤拷锟结倡使锟矫★拷
锟轿硷拷 pg_pconnect()锟斤拷pg_close()锟斤拷pg_host()锟斤拷pg_port(), pg_tty()锟斤拷pg_options() 锟斤拷 pg_dbname()锟斤拷