mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-03 13:37:27 +02:00
README for DataMapper
This commit is contained in:
18
DataMapper/README.md
Normal file
18
DataMapper/README.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Data Mapper
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
A Data Mapper, is a Data Access Layer that performs bidirectional transfer of
|
||||||
|
data between a persistent data store (often a relational database) and an in
|
||||||
|
memory data representation (the domain layer). The goal of the pattern is to
|
||||||
|
keep the in memory representation and the persistent data store independent of
|
||||||
|
each other and the data mapper itself. The layer is composed of one or more
|
||||||
|
mappers (or Data Access Objects), performing the data transfer. Mapper
|
||||||
|
implementations vary in scope. Generic mappers will handle many different domain
|
||||||
|
entity types, dedicated mappers will handle one or a few.
|
||||||
|
|
||||||
|
The key point of this pattern is, unlike Active Record pattern, the data model follows Single Responsibility Principle.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
* DB Object Relational Mapper (ORM) : Doctrine2 uses DAO named as "EntityRepository"
|
@@ -3,25 +3,7 @@
|
|||||||
namespace DesignPatterns\DataMapper;
|
namespace DesignPatterns\DataMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DataMapper pattern
|
* class UserMapper
|
||||||
*
|
|
||||||
* Purpose:
|
|
||||||
* A Data Mapper, is a Data Access Layer that performs bidirectional transfer of
|
|
||||||
* data between a persistent data store (often a relational database) and an in
|
|
||||||
* memory data representation (the domain layer). The goal of the pattern is to
|
|
||||||
* keep the in memory representation and the persistent data store independent of
|
|
||||||
* each other and the data mapper itself. The layer is composed of one or more
|
|
||||||
* mappers (or Data Access Objects), performing the data transfer. Mapper
|
|
||||||
* implementations vary in scope. Generic mappers will handle many different domain
|
|
||||||
* entity types, dedicated mappers will handle one or a few.
|
|
||||||
* (FROM http://en.wikipedia.org/wiki/Data_mapper_pattern)
|
|
||||||
*
|
|
||||||
* The key point of this pattern is, unlike Active Record pattern, the datamodel
|
|
||||||
* follows Single Responsibility Principle.
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* - DB Object Relational Mapper (ORM) : Doctrine2 uses DAO named as "EntityRepository"
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class UserMapper
|
class UserMapper
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user