Chapter 4. Deploying applications with DB2 175
In order to run the application, create a directory and save the application as
itso_phpapp.php. Example4-18 shows how to run the application in detail. The
example demonstrates a successful connection to a remote uncataloged
database.
Example 4-18 A successful connection using itso_phpapp.php
itsouser@ubuntu:~/redbook$ php itso_phpapp.php mensa 50001 test db2inst1
password
Trying to establish connection...
Connection succeeded.
Closing connection..
Connection closed.
If you provide any incorrect information, the connection will fail and an error
message will be thrown. This is shown in Example 4-19.
Example 4-19 Failed connection using itso_phpapp.php
itsouser@ubuntu:~/redbook$ php itso_phpapp.php mensa 50001 test db2inst1
wrongpassword
Trying to establish connection...
[IBM][CLI Driver] SQL30082N Security processing failed with reason "24"
("USERNAME AND/OR PASSWORD INVALID"). SQLSTATE=08001 SQLCODE=-30082
Connection failed.
4.4.6 Deploying a PHP application with the DB2 drivers
In this section, we demonstrate how to deploy a DB2 PHP application with DB2
drivers. We assume that the target system has already have the PHP installed
but the DB2 drivers for PHP are not built during the PHP installation.
These general tasks for deploying a PHP application with ODBC CLI driver are
discussed in the following paragraphs:
򐂰Prepare the DB2 PHP driver and the redistributable DB2 ODBC and CLI
driver files
򐂰Prepare the PHP application package
򐂰Prepare the deployment package
򐂰Deploy the deployment package to the target system
We organize all the deployment files under a directory, php_deploy.