Skip to content

DB2 Database Driver

World Wide Web Server edited this page Jul 4, 2012 · 31 revisions

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 Filename: db2u.zip File:db2u.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 Filename: 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 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'] = "db2c";


Clone this wiki locally