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.

This entry was posted in db2, IBM i, iSeries, Open Source, PHP, System i, Zend Framework and tagged , , , , , , , , , , . Bookmark the permalink.

11 Responses to ZF2 and DB2 for IBM i

  1. Alan Seiden says:

    I’ve updated this post to reflect today’s release of ZF 2.1, which includes a DB2 adapter that works with IBM i.

  2. Andy Youens says:

    Hi Alan

    Does ZF2 have to be installed outside of the Zend Server updates?

    Hotfix 7 does not seem to update ZF1 to ZF2.

    Regards
    Andy Youens

  3. Alan Seiden says:

    Hi, Andy,

    You wouldn’t want an automatic ZF1-to-ZF2 update. ZF2 is a major redesign with its own learning curve.

    At present, you’ll have to download and install ZF2 yourself, which is a good idea anyway, because you’ll get the latest version. Download ZF2 here: http://www.framework.zend.com/.

    Alan

  4. Andy Youens says:

    Thanks for the reply Alan, appreciated.

    Will you be doing any presentations on ZF2 on the IBM I in the near future?

    Best Regards
    Andy

  5. Alan Seiden says:

    Andy, yes, I have a ZF2 on IBM i talk scheduled for COMMON in April, 2013.

    Details here: http://www.alanseiden.com/presentations/upcoming/

    Alan

  6. 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

  7. Andy Youens says:

    Spot on!

    Many thanks Alan

    Regards
    Andy

  8. 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?

    • Alan Seiden says:

      Hi, Rodney,

      The driver should be “IbmDb2″. Have you been successful with DB2 from ZF2 aside from the pagination issue?

      Alan

      • 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?

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>