Data Mapper

Michelangelo van Dam’s Blog: Zend Framework data models

Since data mappers have been introduced in Zend Framework Quickstart lot’s of developers get confused about how to use the same pattern with relations. In one of his recent posts Michelangelo van Dam show to model relations between tables and how to create  complex data models build from data scattered over few dependent tables.

I was struggling getting my data models (as described in the Zend Framework Quickstart) to work with relations. My first solution was to create a database view that merged that data using joins to collect this data in a format that I could use in my data models. This was going great until I looked at my database where it contained over 20 views (along with 20 data models, mappers and db table gateways) ! So I said to myself there had to be another way.

His post is interesting reading for developers who would like to follow data mappers pattern presented in Zend Framework Quickstart and keep their code clean.

Federico Cargnelutti’s Blog: Zend Framework DAL DAOs and DataMappers

Zend Framework’s MVC pattern implementation is often criticized for models not being model as definition says. Zend Framework Team even does not pretend that framework has models, although suggests using Zend_Db component classes as simple and dirty replacement. It does not mean that community can’t do anything about it.

In his latest post Federico Cargnelutti shows how DAO, DAL and Data Mappers can be implemented in Zend Framework. He explains purpose of DAO, DAL and Data Mappers, proposes directory structure for it shows example implementation of all the classes.

His approach is very interesting and ready to use. Who knows, maybe it will be a sparkle for new component proposal, the model.