Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
No description, website, or topics provided.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
|Type||Name||Latest commit message||Commit time|
|Failed to load latest commit information.|
DataMapper * Introduction * Usage * License * Contact Introduction ============ DataMapper is a small library made to create datamappers for database-table based objects (see http://martinfowler.com/eaaCatalog/dataMapper.html). 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 Usage ===== The simplest usage goes something like: require 'datamapper.php'; $mapper = new DataMapper(DB_HOST, DB_DATABASE, DB_USER, DB_PASSWORD, 'mysql'); $mapper->setModelDirectory(PATH_TO_MODELS); $mapper->runProcess(); 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 License ======= This software is licensed under the Apache 2.0 license. License statements should be in the individual files. Contact ======= Questions and anything else can be directed to: peter.e.lind (a) gmail.com