PHP Classes

PHP Object-Relational Mapping

Recommend this page to a friend!

      PHP Classes blog  >  PHP Object-Relational...  >  All threads  >  PHP Object-Relational Mapping  >  (Un) Subscribe thread alerts  
Subject:PHP Object-Relational Mapping
Summary:Confusing persistence layer with Object Relational Mapping?
Author:Jeroen Sen
Date:2008-10-09 19:27:35
Update:2008-10-10 01:05:26

  1. PHP Object-Relational Mapping   Reply   Report abuse  
Picture of Jeroen Sen Jeroen Sen - 2008-10-09 21:29:23
First of all I would like to say that I think you did a great job on writing the piece above. The only thing which bothers me is that it is not about Object Relational Mapping but it is about the use of a persistence layer.

The reason why I say this is that the modeling of your object is dependend on the database. Objects are modeled as tables. In a true Object Relation Mapping situation the implementation of a pattern (like the active record pattern) for building your models just narrows your vision and leads you away from the way you normally would model an object. (In the normal world it would frequently be the case that you model an object like it was an active records but there are also numerous cases where you wouldn't.)

A good starting point to look (and study on) a good example of an Object Relational Mapping prototype with a comprehensive and detailed explanation of all the problems that were ran into can be found in the Java world. In the book "Java Persistence with Hibernate" such a case is described.

These are just my two cents...

  2. Re: PHP Object-Relational Mapping   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-10-10 01:05:26 - In reply to message 1 from Jeroen Sen
That is what the article mentioned. When you depart from the database to model your persistent objects, ActiveRecord pattern is sufficient for simple cases of an object that maps to a single table. For cases with relationships it becomes complicated.

In the case of Metastorage, it generates persistent objects classes code that handles relationships very well and the developer does not have to handle with details such as intermediate tables, like in the case of many-to-many relatioships.