Codeigniter and DataMapper ORM: Part 1

CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications but currently it doesn’t have built-in ORM. Projects such as IgnitedRecord and DataMapper that will help you manage relationship between your models.

We will look into DataMapper and how to use it practically.

DataMapper is an Object Relational Mapper written in PHP for CodeIgniter. It is designed to map your Database tables into easy to work with objects, fully aware of the relationships between each other.

Features

Everything is an object!
Easy to setup, easy to use.
Custom Validation on object properties.
Lazy Loading (related objects are only loaded upon access).
Relations and their integrity are automatically managed for you.
One to One, One to Many, and Many to Many relations fully supported.\
Select data in the style of Active Record (with or without Method Chaining).
Ok let’s start our journey.

Installation

  • Download DataMapper here.
  • Extract the package.
  • Copy application/config/datamapper.php file to your CodeIgniter application/config folder.
  • Copy application/libraries/datamapper.php file to your CodeIgniter application/libraries folder.
  • Copy application/languages/english/datamapper_lang.php file to your CodeIgniter application/language/english folder.
  • Open your CodeIgniter application/config/autoload.php file and add the database and datamapper libraries to the autoload libraries array.

$autoload['libraries'] = array(‘database’, ‘datamapper’);

Share Article/Example:
  • DotNetKicks
  • DZone
  • StumbleUpon
  • Print
  • Add to favorites
  • Digg
  • del.icio.us
  • Twitter
  • Facebook
  • LinkedIn
  • Posterous
  • Slashdot

 

 
eXTReMe Tracker