NYCPHP Meetup

NYPHP.org

[zendframework] a modeling question

Tim Lieberman tim_lists at o2group.com
Tue Jun 2 14:29:42 EDT 2009


> Well, I would ask, is it a crime to have some SQL in your model  
> class -- again, assuming you're comfortable committing yourself to a  
> db for persistence? Also, we can make use of Zend_Db_Table's  
> (and ..._Row)'s higher-level methods (find(), save()) and keep the  
> raw SQL to a minimim, possibly zero.

Absolutely not a crime.

Based on the quickstart example, you could essentially combine the  
model and mapper classes (essentially just move the mapper stuff into  
your model.

That would allow you to continue to leverage Zend_Db_Table, without  
littering your greater modelspace with mapper classes.

Or, you could dispense with Zend_Db_Table completely.  It's not  
terribly useful in a lot of cases.  I usually end up using it only for  
write operations, while any sort of reading is generally driven by  
plain old Zend_Db and Zend_Db_Select.

I would caution you that even if you're 100% sure persistence will  
always be a database, you might want to consider that the database  
platform might change, or you may all of a sudden become enamored with  
Doctrine or something.  So it does pay to keep things appropriate  
abstracted.

-Tim





More information about the zendframework mailing list