Connecting to an IBM DB2 Database with PHP

In my apprenticeship as computer scientist, I’m developing several applications. But now at the end of my apprenticeship i have an IPA (Individual productive work in german Individuelle Produktiv Arbeit). In this work I have to develop a webfrontend in PHP for an application that runs with IBM DB2.
I’ve searched the world wide web for an how to or a tutorial. But I don’t have found any clever hints.

Here is an expample how to connect PHP5 with a IBM DB2 Database in Windows!

First you have to uncomment the following line in your php.ini

extension=php_pdo_odbc.dll

At the second step you have to restart your webserver. In my case it is an Apache Webserver

Now you are ready to connect with PHP to your IBM DB2 Database.
Here is an example:
PHP Code

This code displays you the table (in my case

dbiin

) which you have selected by the select statement.
Here is my result:
PHP Code Result

You can download the source here.

Tags: , , ,

4 Responses to “Connecting to an IBM DB2 Database with PHP”

  1. chris says:

    hy really nice blog,

    just wana ask what theme do you juse?
    can i have it to??

    lg chris

  2. Silas Knobel says:

    hi chris!

    It’s the fSpring theme from http://www.fahlstad.se/
    Greets
    Silas

  3. vince says:

    Warum nutzt du den “langsameren” ODBC Treiber und nicht den offiziellen Treiber von IBM ?

    http://pecl.php.net/package/ibm_db2/
    http://de.php.net/db2

    Der ist von der Performance um einiges besser.

  4. Silas says:

    tjaa das weiss ich jetzt auch nicht so genau :) das ist ja jetzt schon ein weilchen her ;) aber danke für den hinweis!