A DB2 driver for CakePHP

11 February 2007 » DB2, PHP

I’ve just completed the initial version of the IBM DB2 interface that I’ve written for the CakePHP framework.

This driver can also be used with IBM Cloudscape, Apache Derby, and Sun Java DB because it employs the same ibm_db2 PECL extension for connecting to all of these RDBMSes.

There are some wrinkles to iron out, so stay tuned. We’ll be sending out a call for alpha testers shortly.

  

15 Responses to 'A DB2 driver for CakePHP'

Subscribe to comments with RSS


  1. 12 February 2007 at 8:32 am

    Great work Daniel, I’m staying tuned. ;-)

  2. Nate Klaiber said,

    14 February 2007 at 10:24 am

    I am definitely interested in this. We have two DB2 databases running and I just switched to using Cake PHP (1.2) for our internal framework. Currently, I am using an external script to talk to the other databases via PDO – this would make life much nicer :) Ill be sure to keep checking back.


  3. 14 February 2007 at 5:55 pm

    fantastic! i charge $50 an hour! looking forward!

  4. Leo said,

    12 April 2007 at 7:00 am

    Great work you’ve done :)

    I’ve tried to use AdoDB library and was able to get connection to DB with the following conf:
    var $default = array(
    ‘driver’ => ‘adodb’,
    ‘connect’ => ‘odbc_db2′,
    ‘host’ => ‘DRIVER={IBM DB2 ODBC DRIVER};DATABASE=SERVICES;HOSTNAME=localhost;PORT=50000;PROTOCOL=TCPIP’,
    ‘login’ => ‘xxx’,
    ‘password’ => ‘xxx’,
    ‘database’ => ‘services’,
    ‘prefix’ => ”
    );

    The problem is that cake produces a bunch of various errors when it tries to solve table structure and such things on the background.

    Are there any other hope than just wait that your interface is being published as a part of stable cake distro?

  5. krook said,

    12 April 2007 at 7:36 am

    Leo,

    Thanks :)

    Unfortunately the new DB2 driver won’t be available in a stable build until CakePHP 1.2 becomes the production build. There hasn’t been a milestone set yet: https://trac.cakephp.org/milestone/1.2.x.x

    You can get a head start on testing for that release by installing with 1.2 now and helping identify any problems you might encounter.

    Some tips on getting set up:
    http://krook.net/archives/180

    How to submit bugs:
    http://groups.google.com/group/cake-php/browse_thread/thread/61f610f526de417c

    Are you already set up with the ibm_db2 extension in your PHP build?

  6. Leo said,

    12 April 2007 at 8:26 am

    Thanks, i will happily contribute my part for this by doing some testing. :)

    I haven’t setted up ibm_db2 extension, cause i’ve used this
    odbc_db2 “driver” and at AdoDB page
    (http://phplens.com/adodb/supported.databases.html) it says:
    “Connects to DB2 using generic ODBC extension.”
    AdoDB also supports db2 “driver” which is described:
    “Uses PHP’s db2-specific extension for better performance.”
    Is this the same thing than the ibm_db2 extension (http://pecl.php.net/package/ibm_db2)?

  7. Leo said,

    13 April 2007 at 7:26 am

    I just found some bad news:
    http://www.dbforums.com/showthread.php?t=1189508

    “Old ibm_db2 interface of PHP does not support CLOBs/LOBs at all.”
    “For large objects use the PHP PDO class library”

    So basically this means that your interface doesn’t tackle all problems that lie between db2,php and cakephp framework.

    It seems that only working setup is to use PHP5′s PDO class library and this in not supported at cakePHP since cake supports PHP 4 as well.. :(

    So there are probably two choices:
    1. Use PHP5,PDO and DB2 without cakePHP framework
    2. Use PHP4/5 and MySQL/PostgreSQL with cakePHP framework?

  8. krook said,

    13 April 2007 at 10:26 am

    Leo,

    The ibm_db2 driver does support CLOBs, it wouldn’t be much use if it didn’t :).

    In fact, one of the tables in the sample application DDL I developed to test the CakePHP uses a CLOB field.

    From the context of that forum, the older driver that Knut is talking about is the old Unified ODBC driver used with the odbc_* functions, which have many problems, hence the release of a specific DB2 driver (db2_*, ibm_db2 extension).

    Please give the sample application a test, which will show how the CakePHP driver works with CLOB tables in DB2, then try to adapt it to your tables.

    There is also a forum at developerWorks that is monitored by the developers of the ibm_db2 extension and the PDO drivers.

  9. Leo said,

    17 April 2007 at 3:48 am

    Finally i’ve got ibm_db2 extension work together with apache.
    (Needed to reboot system in order to get it working)
    However PHP CLI didn’t needed rebooting and that confused me quite much :)

    Now i’ve tested your example and already made bug report:
    https://trac.cakephp.org/ticket/2444

    I’m using DB2 express v 9.1.0

  10. Daniel Krook said,

    18 April 2007 at 8:19 am

    Hi Leo,

    Thanks for the update. I’ll check out the ticket and try out a fix. Your report is very thorough :)

  11. Leo said,

    19 April 2007 at 2:33 am

    Hi Daniel,

    I’ve noticed that cake tries to use default schema for logged user.
    eg. If i login as db2admin it uses d2admin schema by default.

    I submitted another ticket related to enhancement that one could choose current schema at database.php:
    https://trac.cakephp.org/ticket/2446

  12. gnujach said,

    29 July 2007 at 9:33 pm

    Hi, i can use cakephp with db2 into i5/os?
    thank!

  13. Ambrish Bhargava said,

    29 July 2008 at 1:39 am

    Hi Daniel,

    I am wondering if this project is still live?

    Thanks,
    Ambrish Bhargava

  14. Daniel Krook said,

    29 July 2008 at 8:36 am

    Hi Ambrish,

    Yes it is. In fact I just developed a few fixes last night and hope to merge them into SVN shortly.

  15. Siriu said,

    10 January 2012 at 7:23 am

    Is it possible to use it with cakePHP 2 ?

Leave a Reply