Before you can connect to an IBM® database server and run SQL statements, you
must set up the PHP environment.
Before you begin
You
must have the following required software installed on your system:
- PHP version 5 or later
- If
your PHP application connects to a remote IBM database, the
computer that runs your PHP application requires the IBM Data Server
Client. The PHP
application is not compatible with the following products:
- The IBM Data Server Runtime
Client
product
- The
IBM Data Server Driver Package
product
- The IBM Data Server Driver for
ODBC and CLI
product
If your PHP application connects to an IBM database
server on the local computer, no additional IBM data server
products are required.
Procedure
To install the ibm_db2 and pdo_ibm php extensions:
- Copy
the ibm_db2 and pdo_ibm extension files into the
\ext\
subdirectory
of your PHP installation directory. The ibm_db2 and
pdo_ibm extension files can be obtained from the following sources:
- IBM Data Server product
installation path
- PHP Extension Community Library (PECL)
Note: If you installed the IBM Data Server Driver for
ODBC and CLI software,
you must obtain the ibm_db2 and pdo_ibm extension files separately
from the PHP Extension Community Library (PECL).
- If you have thread safe PHP environment, copy the following
extension files from the IBM Data
Server product installation path into the
\ext\
subdirectory
of your PHP installation directory:
- php_ibm_db2_X_X_XXX_ts.dll
- php_pdo_ibm_X_X_XXX_ts.dll
- If you have non-thread safe PHP environment, copy the following
extension files from the IBM Data
Server product installation path into the
\ext\
subdirectory
of your PHP installation directory:
- php_ibm_db2_X_X_XXX_nts.dll
- php_pdo_ibm_X_X_XXX_nts.dll
- Open the php.ini file in an editor
of your choice. Edit the extension entry in the php.ini file
in the PHP installation directory to reference the PHP driver.
Note: Before
running a PHP script when using the ibm_db2 package, ensure that the php.ini file contains the name
of your
Db2®
instance.
ibm_db2.instance_name=<name_of_the_db2instance>
You can also
source the db2profile from your instance in your PHP script. For more information, see
the PHP
requirements page.
- Optional: If the PHP application that is connecting
to an IBM database server is
running in the HTTP server environment, restart the HTTP Server so
the new configuration settings take effect.