I am not suggesting that all models are tables.
What I am asking is whether every single table must also have its own class defined specifically for it when using Zend? Is there any way of getting away from this awkward boiler-plate coding. We’re just starting to look into Zend (hoping to leave procedural PHP land!) and my colleague thinks this could end up being pretty time-consuming.
Is this the reason for people using ORM solutions? Is there any other way around this?
Thanks for your replies.
The Zend Table classes follow the Table Data Gateway pattern, which by definition
In the book, Fowler is not that rigid about that, saying that
However, except for being able to use Views,
Zend_Db_Tabledoes not accomodate for this. You can create queries to multiple tables, but those would have to be made through theZend_Db_Adapterdirectly or – when using joins – by switching off the integrity check. Otherwise, you have to use the API offered byZend_Db_Table RelationshipsSo yes, one instance should correspond to one table or view. You do not need to create classes for that though if you dont plan on extending the classes.
Zend_Db_Table_Definitionsallow you to configureZend_Db_Tableinstances on the fly.Note that TDG is a DataSource Architectural Pattern and not an Object-Relational pattern. It’s purpose is not to help with impedance-mismatch, but with separating database access code from business logic.