Calling db2_close() on a persistent connection always
returns TRUE, but the underlying DB2 client connection remains open and
waiting to serve the next matching db2_pconnect()
request.

Users running version 1.9.0 or later of ibm_db2 should be aware that the
extension will perform a transaction rollback on persistent connections at
the end of a request, thus ending the transaction. This prevents the
transaction block from carrying over to the next request which uses that
connection if script execution ends before the transaction block does.

Parametri

database

The database alias in the DB2 client catalog.

username

The username with which you are connecting to the database.

password

The password with which you are connecting to the database.

options

An associative array of connection options that affect the behavior
of the connection, where valid array keys include:

autocommit

Passing the DB2_AUTOCOMMIT_ON value turns
autocommit on for this connection handle.

Passing the DB2_AUTOCOMMIT_OFF value turns
autocommit off for this connection handle.

DB2_ATTR_CASE

Passing the DB2_CASE_NATURAL value specifies
that column names are returned in natural case.

Passing the DB2_CASE_LOWER value specifies
that column names are returned in lower case.

Passing the DB2_CASE_UPPER value specifies
that column names are returned in upper case.

CURSOR

Passing the DB2_FORWARD_ONLY value specifies a
forward-only cursor for a statement resource. This is the default
cursor type and is supported on all database servers.

Passing the DB2_SCROLLABLE value specifies a
scrollable cursor for a statement resource. This mode enables
random access to rows in a result set, but currently is supported
only by IBM DB2 Universal Database.

The following new option is available in ibm_db2 version 1.7.0
and later.

trustedcontext

Passing the DB2_TRUSTED_CONTEXT_ENABLE value turns trusted context
on for this connection handle. This parameter cannot be set using
db2_set_option().

This key works only if the database is cataloged (even if the
database is local), or if you specify the full DSN when you create
the connection.

The following new i5/OS options are available in ibm_db2 version 1.5.1
and later.

Sfat

Conflicting connection attributes used in conjunction with persistent
connections can produce indeterminate results on i5/OS. Site policies should
be establish for all applications using each persistent connection user
profile. The default DB2_AUTOCOMMIT_ON is suggested when using persistent connections.

i5_lib

A character value that indicates the default library that will be
used for resolving unqualified file references. This is not valid
if the connection is using system naming mode.

i5_naming

DB2_I5_NAMING_ON value turns on DB2 UDB CLI iSeries
system naming mode. Files are qualified using the slash (/) delimiter.
Unqualified files are resolved using the library list for the job.

DB2_I5_NAMING_OFF value turns off DB2 UDB CLI default
naming mode, which is SQL naming. Files are qualified using the period (.)
delimiter. Unqualified files are resolved using either the default library
or the current user ID.

i5_commit

The i5_commit attribute should be set before the
db2_pconnect(). If the value is changed after the
connection has been established, and the connection is to a remote data
source, the change does not take effect until the next successful
db2_pconnect() for the connection handle.

Notă:

The php.ini setting ibm_db2.i5_allow_commit==0
or DB2_I5_TXN_NO_COMMIT is the default, but may be
overridden with the i5_commit option.

DB2_FIRST_IO All queries are optimized with the goal of
returning the first page of output as fast as possible. This goal works well
when the output is controlled by a user who is most likely to cancel the query
after viewing the first page of output data. Queries coded with an
OPTIMIZE FOR nnn ROWS clause honor the goal specified by the clause.

DB2_ALL_IO All queries are optimized with the goal of running
the entire query to completion in the shortest amount of elapsed time. This is a
good option when the output of a query is being written to a file or report, or
the interface is queuing the output data. Queries coded with an OPTIMIZE FOR nnn
ROWS clause honor the goal specified by the clause. This is the default.

Exemple

Example #1 A db2_pconnect() example

In the following example, the first call to
db2_pconnect() returns a new persistent connection
resource. The second call to db2_pconnect() returns
a persistent connection resource that simply reuses the first persistent
connection resource.