Tip

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!


 
 require_once("my.fasdab.odbc.php");
//
// I put the connection options in a new class in a only file.
$db_literals_clau = new my_fasdab();
$db_literals_clau->query($sqlstm);
$row_literals_clau=$db_literals_clau->row();
$resultat = "n<h3>" . $row_literals_clau->LIT_TXT . "</h3>n"; 

==================================
MORE INFORMATION ON THIS TOPIC
==================================

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.

This was first published in July 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.