Im trying connecting IBM DB2 database from php with apache as webserver all of them on windows platform......

The senario is as such:
I have apache + php 4 on windows platform on one machine...
I have IBM DB2 on the remote machine (on windows platform).
1) So my question is that how do i get php to access DB2 on a remote machine.? What are the drivers and where we can fine and how to configure it..???

2) if some one knows the connection part can they send me the code ???

3) please also tell me how to configure httpd.conf file in apache to utilise the DB2 driver...

Regards
Mac

    5 months later

    I have a similar situation, except that the database is on an as400.

    I've been reading about installing php using "--with-ibm-db2[=DIR]". How do I do that in XP? Is it already part of the unified odbc functions?

    This is my test page:

    $saved = getenv("LD_LIBRARY_PATH");
    $newld = "C:\IBM\DB2EE\lib"; // extra paths to add
    if ($saved) { $newld .= ":$saved"; } // append old paths if any
    putenv("LD_LIBRARY_PATH=$newld"); // set new value

    $newDB2 = "db2connect";
    putenv ("DB2INSTANCE=$newDB2");

    $dbname = "DBAS400";
    $cur = SQL_CUR_USE_ODBC;

    $connect = odbc_connect($dbname, $user, $pwd, $cur);

      Well, I did it...

      After reading all that linux documentation, xp is a snap.

      I installed php manually in xp using the instructions on the php site. No need to worry about "--with-ibm-db2" or anything.

      apache/conf/httpd.conf needs
      [FONT=courier new]ScriptAlias /php/ "c:/php/"
      AddType application/x-httpd-php .php
      Action application/x-httpd-php "/php/php.exe" [/FONT]
      added to the bottom.

      c:\windows\php.ini needs
      [FONT=courier new]doc_root[/FONT]

      changed to
      [FONT=courier new]doc_root = "c:\program files\apache group\apache2\htdocs"[/FONT]

      Download DB2 Personal Developer Edition from IBM. This package includes DB2 Connect Personal Edition v8.1 - the only element that you need to install on your apache machine.

      Run Configuration Assistant. Under "Selected", click Add a Database. Fill in the details of your DB2 server. The port should be 446. I found [URL=ftp://ftp.software.ibm.com/ps/products/db2/info/vr8/pdf/letter/db2c6e80.pdf]this (go to Ch.11)[/URL] to be lots of help, especially the DSPRDBDIRE command!

      note - you need to have administrative/poweruser rights on both your Windows network and IBM server.

      When Config Assistant can successfully connect using ODBC, go to Start > Programs > Administrative Tools > Data Sources (ODBC). Your db connection should be listed under System DSN. Double click on it, and click on Bind CLI/ODBC Support Utilities. WAIT for a result box to appear. It took my machine a minute or so.

      Now you should be ready to go!

      In apache/htdocs/myconnect.php put:
      [FONT=courier new]
      $cur = SQL_CUR_USE_ODBC;
      $connect = odbc_connect($dbname, $user, $pwd, $cur);
      // where $dbname is the one from the DSPRDBDIRE command
      $query = "SELECT * FROM AS400LIBRARYNAME.TABLENAME";
      $result = odbc_exec($connect, $query);
      [do stuff here]
      odbc_close($connect);
      [/FONT]
      then go to http://localhost:8080/myconnect.php (or whatever port apache's listening on - mine's 8080.)

      🆒

        Write a Reply...