Zend Framework 1.7: Zend_Db_Table still sucks
Posted by John Kleijn • Sunday, November 30. 2008 • Category: Zend FrameworkZend Framework is now at version 1.7, adding better internationalization support, and supporting the Dijit Editor Widget. Ok, better internationalization support can only be good (since it was already more than decent), but the Editor Dijit should have been in 1.6. I gave the Dojo support in 1.6 a test drive when it was first released, only to find that it was mostly useless. Hopefully that has changed, I haven't tried it yet.
Don't get me wrong, I love Zend Framework, but it has (at least) one Achilles Heel: Zend_Db_Table. Fairly recently I gave it another go, drew up some ERDs and tried to use the Zend_Db_Table to map to the database. This resulted in a lot of frustration and curses and me throwing Zend_Db_Table back in the dust bin in favour of Doctrine.
The bottom line is Zend_Db_Table does a very poor job of bridging the Object-relational impedance mismatch. Oh, if you keep you schema simple and violate a handful of normalization rules, in other words, reckon for the fact you will be using Zend_Db_Table when you create it, it will work fairly well. You will still have unnecessary trips the database though. Which brings us to the main cause of all this aching, Zend_Db_Table does not support joining tables and joined rows. One may argue that this is inherent to the pattern(s) used, Table/Row Data Gateway. Yes, you may have a point, but does this mean we should be forced to deal with this limitation, rather than demand it be lifted in whatever way it can? No pattern implementation is cast in stone, and it would be possible to support joining tables, resulting in joined Rows, before you query them. Maybe that brings it closer to an Active Record implementation, but is that a crime?
Yet, it doesn't seem like anyone at Zend is worried about this. Me, I have aggravated myself at Zend_Db_Table for the last time, I'm throwing it in the dustbin, permanently. Doctrine may be slower than Zend_Db_Table, at least I can get joined Active Records, and use a properly normalized database, even apply a little Class Table Inheritance where applicable, the other mayor miss in Zend_Db_Table. And no, Doctrine isn't perfect (Why does every PHP ORM use Active Record -- when are we going to see a Domain Object/Data Mapper implementation?), but it kicks Zend's ass and Zend doesn't seem to be a bit worried about it.



ShareThis