I'm working on a PHP MVC project, and the type of data interaction with the database is enough to facilitate the inclusion of a data access layer. The view will use Ajax to pass JSON objects to the controller for processing.
For the controller actions that require executing DAO functions, which is best:
- Package incoming JSON into model objects and pass to DAO function
- Pass incoming JSON data directly to DAO
Right now, I'm using option 1, since the views are being developed in parallel to the controller/DAO layers and packing the data within objects is easier for writing tests. When it comes to production, however, I am unsure if this is a good idea.