GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DesignPatternsPHP/Structural/DataMapper at master · Serious-Rage/DesignPatternsPHP

Expand file tree

/

DataMapper

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

DataMapper

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Tests
Tests
 
 
uml
uml
 
 
README.rst
README.rst
 
 
User.php
User.php
 
 
UserMapper.php
UserMapper.php
 
 

README.rst

Outline

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"

UML Diagram

Alt DataMapper UML Diagram

Code

You can also find these code on GitHub

User.php

.. literalinclude:: User.php
   :language: php
   :linenos:

UserMapper.php

.. literalinclude:: UserMapper.php
   :language: php
   :linenos:

Test

Tests/DataMapperTest.php

.. literalinclude:: Tests/DataMapperTest.php
   :language: php
   :linenos:

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.