ZF2 and DB2 for IBM i

I’d like to address questions about DB2 support in Zend Framework 2.x. Because I helped create the IBM i-friendly DB2 adapter for Zend Framework 1.x, I’ve followed the development of a similar adapter for ZF2.

(updated January 30, 2013, upon the release of ZF 2.1)

Q. Does ZF 2 include an adapter for DB2?
A. Yes! Starting with ZF 2.1, which was released today.

Q. Is Alan’s IBM i-friendly DB2 adapter for Zend Framework 1.x needed in 2.x?
A. No. Because ZF’s Zend_Db equivalent in 2.x works differently than in 1.x, my 1.x component is not needed in 2.x.

Q. Does ZF 2.1’s DB2 adapter work with IBM i?
A. Yes! Please try it and provide feedback to the ZF team.

11 replies
  1. Rodney
    Rodney says:

    Hey Alan,
    I’m currently working on a zf2 app on the ibmi. I have it mostly workin except for paginating result sets with the Zend\Paginator\Adapter\DbSelect. Db2 doesn’t support the LIMIT and OFFSET function, which I know are not ANSI SQL, but I have another zf1 app on the i that uses the paginator dbselect and it works great. Just wondering if the zf2 app is not using the native ibmiDb2 driver/adapter. Would happen to know the proper driver and adapter name?

    Reply
      • Rodney
        Rodney says:

        I would say yes up to this point. I have run into some other inconsistencies with the Zend\Db\Sql\Select with ZF2. Using the methods in this class to build Sql statements do not always give you the expected results. I’m finding its better to just write the statements long hand, prepare them and then execute. Gives up some abstraction when and if we need to move it to a different platform or Db but at least the project keeps moving :)

        The paginator is a big issue right now since I’m working with a very large tables and bringing back the entire result set, then paginating over it is not an option.

        The zf2 docs say that I should extend the paginator’s DbSelect class and override the getItems method and implement a custom limit and offset routine. Easy enough, but I’m struggling a bit with the correct sql that Db2i could use to simulate this. How would you handle this?

        Reply
  2. Alan Seiden
    Alan Seiden says:

    To answer your original question, Andy, Hotfix 7 does include Zend Framework 2.02, but it’s installed in a separate folder from ZF 1. Therefore, your applications won’t automatically update, which is good, because ZF2 is quite different from ZF1. What’s more, ZF 2.02 didn’t have a DB2 adapter. The DB2 adapter was shipped with the later release 2.1.

    Here are the paths where ZF1 and 2 are installed by default:
    ZF1: /usr/local/zendsvr/share/ZendFramework
    ZF2: /usr/local/zendsvr/share/ZendFramework2

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.