views:

59

answers:

2

I am very experienced with the CakePHP framework but am checking out the Zend Framework for an application that will receive massive traffic.

I'm going through the quickstart tutorial in the documentation and got to the "Create a Model and Database Table" page.

Must I or should I create all those model classes it mentions, i.e.

application/models/DbTable/Guestbook.php application/models/GuestbookMapper.php application/models/Guestbook.php

Coming from CakePHP it seems like quite a lot of code for some functionality I would of thought of as quite basic and generic.

Or can I just create application/models/Guestbook.php and have it extend Zend_Db_Table_Abstract?

Any help would be much appreciated.

+1  A: 

You can create your model after the DbTable class, however one of the benefits of doing a dataMapper class between your model and your DbTable class is that you can abstract more the data engine and create strong business rules.

Chris
+1  A: 

Zend Framework does not actually impose any restrictions or requirements on your Model classes and you are free to create them however you would like.

Depending on the requirements and scope of the project I generally still go with subclassing Zend_Db_Table_Abstract (often with my own custom extension of it as well). When it comes to a large or complicated project I have found that using a dataMapper pattern has been very helpful.

At the same time I have had some models that do not extend any class at all. They simply are there to provide some logic and do not relate to a database.

Mike