« Return to Thread: MVC - where can I learn more about the "model"?

Re: MVC - where can I learn more about the "model"?

by Pádraic Brady :: Rate this Message:

Reply to Author | View in Thread

My typical explanation of the Model...

The Model is responsible for maintaining state between HTTP requests in a PHP web application. Any data which must be preserved between HTTP requests is destined for the Model segment of your application. This goes for user session data as much as rows in an external database. It also incorporates the rules and restraints governing that data which is referred to as the "business logic". For example, if you wrote business logic for an Order Model in an inventory management application, company internal controls could dictate that purchase orders be subject to a single purchase cash limit of €500. Purchases over €500 would need to be considered illegal actions by your Order Model (unless perhaps authorised by someone with elevated authority). Models are therefore the logical location for data access but may also act as a central location for examining, verifying and making final manipulations on that data before it's stored, and even after it's retrieved.

It really can be anything representing data - database, XML, web services, RSS, CSV files, sessions, etc. The only real constraint is the data is preserved between requests (for PHP at least)

Best regards,
Paddy


tfk wrote:
Less database (RDBMS)-centric - we use Rest and Xmlrpc in the model very often.

Cheers,
Till

On Tue, May 13, 2008 at 5:58 PM, Wil Sinclair <wil@zend.com> wrote:
> That's not entirely true. Anything in ZF can be a model at this point.
>  We will be introducing a model formalism in the future, but we'd like to
>  capture the flexibility that many projects require for their models to
>  do so.
>  Greg is right that the Zend_Db tables are the closest thing we have to a
>  database-backed model. Also consider the fact that you can use full ORM
>  solutions like Propel and Doctrine for your model as well.
>
>  ,Wil
>
>
>
>  > -----Original Message-----
>  > From: Greg Donald [mailto:gdonald@gmail.com]
>  > Sent: Tuesday, May 13, 2008 8:48 AM
>  > To: fw-general@lists.zend.com
>  > Subject: Re: [fw-general] MVC - where can I learn more about the
>  > "model"?
>  >
>  > On 5/13/08, Rishi Daryanani <rishijd@yahoo.com> wrote:
>  > >  I have
>  > >  not yet come across any mention of the "models"
>  > >  subdirectory.
>  > >
>  > >  Where can I learn more about this and what it's used
>  > >  for?
>  >
>  > ZF doesn't have what you may have come to expect as an actual "model"
>  > component from other web frameworks.  Instead it has Zend_Db and
>  > Zend_Db_Table.
>  >
>  >
Pádraic Brady

http://blog.astrumfutura.com
http://www.patternsforphp.com
OpenID Europe Foundation - Irish Representative

 « Return to Thread: MVC - where can I learn more about the "model"?