DataMapper ORM vs. Doctrine DataMapper ORM vs. Doctrine codeigniter codeigniter

DataMapper ORM vs. Doctrine


DataMapper ORM and Doctrine follow a completely different set of conventions. The DataMapper ORM is (confusingly enough) not a data mapper but an active record implementation. That means that your model classes are tightly integrated with the ORM library. Your models build on the built-in DataMapper models. You get a lot of magic for free but in exchange you marry your models to the DataMapper ORM.

Doctrine on the other hand uses a true data mapper pattern. It's models are plain old PHP objects. They have no external dependencies. Doctrine can take any old PHP object, store it in a database and later retrieve it again. It's models are not coupled with the ORM at all.

The things you read about in the Doctrine documentation about getters, setters, relational integrity, etcetera, they are just good OO development practices. They are not a requirement for Doctrine but they make your life easier. You should be using them for your DataMapper ORM models too! If you want, you could use magic getters and setters or even just plain old public properties on your Doctrine models. Just because Doctrine says that you shouldn't do it does not mean that you cannot do it. Doctrine will happily use your models with public properties, but there are some caveats. That's all.