In this post, we are going to do a recipe mixing those few ingredients: PHP, DB2 and unixODBC.
One of the project in my new job in Rome is to develop an application in PHP that works with an AS/400 DB2 database. I’ve been working with PHP and databases such as MySQL for quite some years now, instead, it has been my first encounter with DB2, so the challenge was interesting.
I did some search before even starting anything, and it seems there is mainly 2 ways of using DB2 with PHP : 1. install a IBM DB2 client on the computer where PHP is and build the ibm_db2 extension. 2. use DB2 with ODBC and the unixODBC drivers. This article explains how to make unixODBC to work with an AS/400 DB2 database on a Linux (CentOS) machine to access it with PHP.