CakePHP DB2 driver alpha released

22 February 2007 » DB2, PHP

The CakePHP team has included the ibm_db2 driver that I submitted in the latest 1.2 development branch.

I’ve sent out a call for alpha testers to put it through its paces.

You can get up and running quickly by:

  • Extracting the sample application (thanks Nate) which provides a skeleton for working with CRUD operations and table associations (hasOne, hasMany, belongsTo, hasAndBelongsToMany) to your “app” directory.
  • Creating a database.
    [code lang=”sql”]
  • Creating the database tables from the DDL.
    [code lang=”bash”]
    [db2inst1@]$ db2 connect to cake
    [db2inst1@]$ db2 -tf db_test_db2.sql
  • Updating your database.php configuration.
    [code lang=”php”]
    // DB2
    var $default = array(
    ‘driver’ => ‘db2’,
    ‘connect’ => ‘db2_connect’,
    ‘host’ => ‘localhost’,
    ‘login’ => ‘db2inst1’,
    ‘password’ => ‘password’,
    ‘database’ => ‘cake’,
    ‘prefix’ => ”,
    ‘encoding’ => ‘UTF-8’
  • Retarting your Web server.

Please try it out and submit your bug reports to Trac with “DB2” in the title. Information on the particular database product, platform and version you are using would be helpful as well.


6 Responses to 'CakePHP DB2 driver alpha released'

Subscribe to comments with RSS

  1. Dinshaw said,

    23 October 2007 at 1:55 pm

    I had to kame a couple changes to the driver to get it to work with the free edition of db2.

    1. db2_num_rows returns -1 for a SELECT statement.
    The docs say that if you pass array(‘cursor’ => DB2_SCROLLABLE) to your execute statement then db2_num_rows will return a result but it did not work for me.

    2. The way the describe array is created seems to be incompatable with the CakePHP’s Set::extract method

    my fixes are here but i am sure there is a cleaner way

  2. Daniel Krook said,

    31 October 2007 at 3:50 pm

    Hi Dinshaw,

    I replied to the trac ticket at I can’t seem to run your changes locally, can you send me the file directly?


  3. Steve Hiller said,

    22 February 2008 at 9:22 pm

    Hi Daniel,

    Please let me know what is the current status of your DB2 driver for cakephp. I am considering using cake for a new project where the data lives in a DB2 database held on an AS/400 (iseries) computer. Will the driver work with that database?

    Thanks for your help,

  4. Stefan Leuckx said,

    21 April 2008 at 7:40 am

    Hi Daniel,

    I did some small tests and had some problems (see also bug #4458), as an evaluation of the framework.
    I like the cake framework, but was wondering about the DB2 driver: what is the current status of the DB2 driver?
    Do you still work on/with cake, or in the near future and DB2?


    Stefan Leuckx

  5. Daniel Krook said,

    22 April 2008 at 11:19 pm

    Hi Stefan,

    I hadn’t made updates in a while, but I recently received commit rights on the driver, so I intend to be more active maintaining it. Please do continue to report problems and I will try to address them in a timely fashion.

  6. Salfa said,

    06 May 2008 at 2:23 am

    Hi daniel.

    I have one application with the db2 driver, but i have one problem, when the connection is done and i try to describe the model, the result is wrong, the columns types are something like this ‘åÁÙÃÈÁÙ’, and obviously cakephp dont work fine, because i can’t to determine the column type from tables. Can you tell me if the driver is stable or something i have to include?

    Thanks for you help.

Leave a Reply