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.
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?
Hi, Rodney,
The driver should be “IbmDb2”. Have you been successful with DB2 from ZF2 aside from the pagination issue?
Alan
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?
Rodney,
I posted an answer on how to simulate LIMIT (a non-standard clause but made popular by MySQL):
http://forums.zend.com/viewtopic.php?f=77&t=115573
Best regards,
Alan
Spot on!
Many thanks Alan
Regards
Andy
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
Andy, yes, I have a ZF2 on IBM i talk scheduled for COMMON in April, 2013.
Details here: https://www.seidengroup.com/presentations/upcoming/
Alan
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
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
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
I’ve updated this post to reflect today’s release of ZF 2.1, which includes a DB2 adapter that works with IBM i.