PHP.nl

pg_pconnect

pg_pconnect

Open a persistent PostgreSQL connection

 **pg_pconnect** string $connection_string int $flags
opens a connection to a

PostgreSQL database. It returns a instance that is needed by other PostgreSQL functions. pg_pconnect``PgSql\Connection

If a second call is made to with the same as an existing connection, the existing connection will be returned unless you pass as . pg_pconnect``connection_string``PGSQL_CONNECT_FORCE_NEW``flags

To enable persistent connections, the

php.ini directive must be set to (which is the default). The maximum number of persistent connections can be defined with the

php.ini directive (defaults to for no limit). The total number of connections can be set with the

php.ini directive. pgsql.allow_persistent"On"pgsql.max_persistent-1pgsql.max_links

will not close persistent links

generated by . pg_close``pg_pconnect

connection_string The can be empty to use all default parameters, or it can contain one or more parameter settings separated by whitespace. Each parameter setting is in the form . Spaces around the equal sign are optional. To write an empty value or a value containing spaces, surround it with single quotes, e.g., . Single quotes and backslashes within the value must be escaped with a backslash, i.e., and . connection_string``keyword = value``keyword = 'a value'``\'``\\

   The currently recognized parameter keywords are:
   , , ,
   , ,
   , ,
   ,  (ignored), ,
    (deprecated in favor of ), and
   .
   Which of these arguments exist depends on the PostgreSQL version.
  `host``hostaddr``port``dbname``user``password``connect_timeout``options``tty``sslmode``requiressl``sslmode``service`

flags If is passed, then a new connection is created, even if the is identical to an existing connection. PGSQL_CONNECT_FORCE_NEW``connection_string

Returns a instance on success, return.falseforfailure. PgSql\Connection

**Voorbeeld: Using **

<?php
// Connect to a database named "mary"
$dbconn = pg_pconnect("dbname=mary");

// Connect to a database named "mary" on "localhost" at port "5432"
$dbconn2 = pg_pconnect("host=localhost port=5432 dbname=mary");

// Connect to a database named "mary" on the host "sheep" with a username and password
$dbconn3 = pg_pconnect("host=sheep port=5432 dbname=mary user=lamb password=foo");

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

pg_connectPersistent Database Connections