Skip to content
Switch branches/tags
Go to file

Latest commit


Git stats


Failed to load latest commit information.



* Introduction
* Usage
* License
* Contact

DataMapper is a small library made to create datamappers for database-table
based objects (see I
didn't like what I found in Zend, and as a learning exercise I created this.

The design theory is that a row-object should be as easy to interact with
as possible: this means dealing with properties, not methods. It should also
be fast in use, this means no magic methods. It should be easy to update
the objects in case of schema changes to the database, this means decoupling
saving and loading of the object from object itself, and having autogenerated
code for saving and loading. This leads to the following design:
- one class for the actual objects, one class to take care of loading/saving
  the object data to the database
- data is accessed on the model-object purely through properties - all fields
  from the database are set as public properties
- upon save, the datamapper object checks what data can be saved, taking
  such things as primary key into consideration (manual specification of a
  primary key is not allowed without a specific override)
- the generate process of the library can be run as often as is needed. It
  will by default overwrite datamapper classes but not model classes. This
  behaviour can be defined

The simplest usage goes something like:

require 'datamapper.php';
$mapper = new DataMapper(DB_HOST, DB_DATABASE, DB_USER, DB_PASSWORD, 'mysql');

There are a number of things that can be customized though, by calling methods
on the DataMapper object before calling runProcess(), such as:
- setMapperDirectory
- setModelExtendClass
- setModelPrefix
- overWriteModels
- setTranslationMode

To get output while running the process (for debugging purposes or curiosity),
use the setVerbosityLevel() method

This software is licensed under the Apache 2.0 license. License statements
should be in the individual files.

Questions and anything else can be directed to:
peter.e.lind (a)


No description, website, or topics provided.



No releases published


No packages published