Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IBM DB2 connection

Status
Not open for further replies.

Hokey

MIS
Oct 28, 2000
178
US
Anyone know of tutorials, information, etc. on connecting PHP to an IBM AS400 DB2 server. I know that there is the with-ibm-db2 option in the compile configuration, so PHP supports it, I am just having troubles finding any additional information on how this is accomplished.

Thanks
 
By going to " and searching for

php ibm db2

I found this:
--------

To connect IBM DB2 to PHP under linux (UNIX in general) is quite simple.

First you must install the DB2 including the software develooper kit.
(Is on teh default instalation for Linix.)

Compile PHP with the --with-ibm-db2=/your/path/to/the/db2inst1/sqllib
option (for example: "./configure --with-pgsql --with-ibm-
db2=/disks/8gig/home/db2ins71/sqllib --without-gd --enable-ftp --with-
apache=../apache_1.3.12 --enable-track-vars" then compile the Apache
server like usual.

In PHP use the odbc_* function calls to do the rest.

Example:
$Link_ID=odbc_pconnect("databasename","user","Password");
$Query_ID = odbc_do($Link_ID,"SELECT a,b FROM some_sheame.some_table");
$i=1;
$res=odbc_fetch_row($Query_ID,$i);
while($res)
{
print("A:".odbc_result($Query_ID,"a")." B:".odbc_result
($Query_ID,&quot;b&quot;).&quot;<BR>&quot;);
$res=odbc_fetch_row($Query_ID,$i);
}
odbc_free_result($Query_ID );
odbc_Close($Link_ID);

PHP also instals a DB class hirachy whitch I recommend. It's default
locatet at:/usr/local/lib/php/DB.php

Good luck
----------------------------------

I'm sure there's more useful info to be found there. I've also seen other references which instruct you to use the odbc() functions after configuring in --with-ibm-db2 as stated above.

HTH.
Hardy Merrill
Mission Critical Linux, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top