262 DB2 Deployment Guide
/* disconnect from the database */
printf("\n Disconnecting from the database %s...\n", dbname);
cliRC = SQLDisconnect(hdbc);
}
/* free connection handle & environment handle */
cliRC = SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
cliRC = SQLFreeHandle(SQL_HANDLE_ENV, henv);
}
A.2 PHP

Example A-2 shows the application used to demonstrate the deployment of the

DB2 PHP application.

Example: A-2 Sample PHP application
<?php
/* A sample php application.
Use this program to test connection to a database.
Database connectivity information is read as command line arguments.
Give arguments in the following order:
hostname port_number database_name user password
Run the application as following:
php itso_phpapp.php hostname port_number database_name user password
*/
# Varifying the number of command line arguments.
if($argc != 6) {
printf(" ERROR: incorrect command line arguments.\n Use hostname
port_number database_name user_name password\n", $argv[0]);
exit(1);
}
# Creating dsn from command line arguments.
$dsn = "HOSTNAME=" . $argv[1] .
";PORT=" . $argv[2] .
";DATABASE=" . $argv[3] .
";PROTOCOL=TCPIP" .
";UID=" . $argv[4] .
";PWD=" . $argv[5];
print "Trying to establish connection...\n";