Skip to content

DB2 Database Driver

strikesam edited this page Sep 12, 2012 · 31 revisions

Don't read any further. Driver files are untreaceable.

I've created some IBM DB2 drivers for CodeIgniter 1.5.4 (I'm sure you can adapt them to earlier versions too), and figured I'd let others who were searching for the same thing have access to them. I've got two different versions, one is a driver for cataloged databases on your local host, and the other is for uncataloged remote database connections. These two versions are almost identical except for the the method they use to connect. There are a few things that are required for these drivers to work successfully.

  1. You must have the ibm_db2 PECL extension installed, otherwise, none of the functions will be recognized.

  2. You must have a DB2 database or client utility installed on your local machine for the ibm_db2 PECL extension to work properly.

When those are up and running, feel free to use the DB2 drivers provided below. If you wish to improve, or make changes please let me know. Just find my CI profile, and email me.


DB2 Uncataloged or Remote Connections Download: File:db2u_v3.zip

Take the zip file, extract the contents of it to your system/database/drivers folder of your CodeIgniter installation. Make sure the following 5 elements are defined properly in your database config file. All 5 elements are required to successfully connect, and use, especially the database name element.

$db['default']['hostname'] = "HOSTNAME"; $db['default']['username'] = "username"; $db['default']['password'] = "password"; $db['default']['database'] = "DBNAME"; $db['default']['dbdriver'] = "db2u";


DB2 Cataloged Connections - Updated by David Bates 05/19/2009 Download: File:db2c.zip

Take the zip file, extract the contents of it to your system/database/drivers folder of your CodeIgniter installation. Make sure the following 4 elements are defined properly in your database config file. All 4 elements are required to successfully connect, and use, especially the database name element. You'll notice that hostname is not really required, seeing as your database has been cataloged, simply enter a dummy value or 'localhost' to remind yourself of this. If you want to use the options array provide the desired options in the 'options' array segement. The option show below is specifically for os/400 - i5/OS.

$db['default']['username'] = "username"; $db['default']['password'] = "password"; $db['default']['database'] = "DBNAME"; $db['default']['dbdriver'] = "db2c"; $db['default']['options'] = array('i5_lib' => 'TSTDTA');


Download File:db2u_v2.zip (DB2 Uncataloged or Remote Driver) Download File:db2c.zip (DB2 Cataloged Driver)

Download File:db2u_v3.zip (DB2 Uncataloged or Remote Driver) for CI 1.7.2 - Fixes by Drew Yeaton

Clone this wiki locally