Problem solve Get help with specific problems with your technologies, process and projects.

Fast access to DB2 on the iSeries with PHP

Here's an easy way to get fast access to DB2 on the iSeries with PHP.

I have a dream: Access DB2 on the iSeries with an Web-based application written in PHP.

Following these steps, I made that dream a reality.

First, I installed a W2K (512Mb) machine with CA an ODBC driver to access to the DB2 database. It does run, but it's slow.

On a Linux machine (128 Mb)-- with the last ODBC driver for Linux -- the same application runs twice as fast as the W2K machine.

I installed a RedHat 7.1 with server default options, and upgraded the Kernel, Apache, and PHP with RPM's downloadeds from the RedHat Web site. Don't forget to change the LILO config file to point to the new kernel.

Then I installed the RPM of unixODBC and the PHP RPM to enable ODBC connections.

Next I installed the IBM iSeries ODBC driver for Linux, and ran shell (the ODBCConfig command to enable a system connection to the iSeries). If you have any problems, read the how-to on the Web and make this step manually -- it's easy. To test the connection at shell put:
isql yourODBCname youriSeriesUser your password and run a SQL command.

Then, the Apache Server with PHP ODBC connection runs, makes a phpinfo() script to verify the options. If you don't find the RPM's, go to the well page.

To make the ODBC access from PHP easier, I used the fasdab class. That returns the column values as property values of an object at Fasdab.

That's all... It runs fast... It born easy!

// I put the connection options in a new class in a only file.
$db_literals_clau = new my_fasdab();
$resultat = "n<h3>" . $row_literals_clau->LIT_TXT . "</h3>n"; 


The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

Dig Deeper on iSeries CL programming