These functions enable you to access IBM DB2 Universal Database, IBM Cloudscape, and Apache Derby databases using the DB2 Call Level Interface (DB2 CLI).
To connect to IBM DB2 Universal Database for Linux, UNIX, and Windows, or IBM Cloudscape, or Apache Derby, you must install an IBM DB2 Universal Database client on the same computer on which you are running PHP. The extension has been developed and tested with DB2 Version 8.2.
To connect to IBM DB2 Universal Database for z/OS or iSeries, you also require IBM DB2 Connect or the equivalent DRDA gateway software.
The user invoking the PHP executable or SAPI must specify the DB2 instance
before accessing these functions. You can set the name of the DB2 instance
php.ini using the
configuration option, or you can source the DB2 instance profile before
invoking the PHP executable.
If you created a DB2 instance named
/home/db2inst1/, for example, you can add the
following line to
If you do not set this option in
php.ini, you must issue the
following command to modify your environment variables to enable access to
bash$ source /home/db2inst1/sqllib/db2profile
To enable your PHP-enabled Web server to access these functions, you must
either set the
php.ini, or source the DB2 instance environment in your Web
server start script (typically
To build the ibm_db2 extension, the DB2 application development header files and libraries must be installed on your system. DB2 does not install these by default, so you may have to return to your DB2 installer and add this option. The header files are included with the DB2 Application Development Client freely available for download from the IBM DB2 Universal Database » support site.
If you add the DB2 application development header files and libraries to a Linux or Unix operating system on which DB2 was already installed, you must issue the command db2iupdt -e to update the symbolic links to the header files and libraries in your DB2 instances.
ibm_db2 is a » PECL extension, so follow the instructions in Chapter 5, Installation of PECL extensions to install the ibm_db2 extension for PHP. Issue the configure command to point to the location of your DB2 header files and libraries as follows:
bash$ ./configure --with-IBM_DB2=/path/to/DB2
The configure command defaults to
If you are using the ibm_db2 driver with Microsoft Internet Information Server (IIS) you may have to do the following:
|Install DB2 with extended operating system security.|
|Add the PHP binary path to the PATH system environment variable (default C:\php\).|
|Create another system environment variable equal to the path where the PHP.INI file is located (eg: PHPRC = C:\php\).|
|Add the IUSR_COMPUTERNAME to the DB2USERS group.|
The behaviour of these functions is affected by settings in
|ibm_db2.i5_allow_commit||"0"||PHP_INI_SYSTEM||Available since ibm_db2 1.4.9.|
|ibm_db2.i5_dbcs_alloc||"0"||PHP_INI_SYSTEM||Available since ibm_db2 1.5.0.|
|ibm_db2.instance_name||NULL||PHP_INI_SYSTEM||Available since ibm_db2 1.0.2.|
Here's a short explanation of the configuration directives.
This option controls the mode used for converting to and from binary data in the PHP application.
This option controls the commit mode used for i5 schema collections in the PHP application.
0 no commit (see i5_commit for override)
1 allow commit (see i5_commit for override)
This option controls the internal ibm_db2 allocation scheme for large DBCS column buffers.
0 no expanded allocations (see i5_dbcs_alloc for override)
1 use expanded allocations (see i5_dbcs_alloc for override)
On Linux and UNIX operating systems, this option defines the name of the instance to use for cataloged database connections. If this option is set, its value overrides the DB2INSTANCE environment variable setting.
This option is ignored on Windows operating systems.
The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.
The ibm_db2 extension returns connection resources, statement resources, and result set resources.
Table of Contents