PdoMap (PHP)

pdoMap is a PHP ORM (object-relational mapping) framework released under (LGPL). The main aim of this project is to provide to PHP developers a RAD framework and a new way of dealing with databases.

History

The project was started in April 2008 :

  • 1.x version (from april 2008 to september 2009) :

This version was based on the XSD datasource mapping format provided by .NET datasets. This version is available on repository at : http://pdomap.svn.sourceforge.net/viewvc/pdomap/tags/1.5/

  • 2.x version (from september 2009 to now) :

Project was restart from scratch based on a new XML format, closer to Hibernate format declaration.

Usage demonstration

pdoMap combines the ACTIVE record pattern and the adapter pattern to map each table resulting in two classes for each database table. One represents a record entity, and the other one represents a service adapter for the table.

For example, the following PHP code CREATES a new user :

 $user = pdoMap::get('users')->Create();
 $user->Name = "john";
 $user->Password = md5("doe");
 $user->Flush();

In order to get this user from database, there's no need in selecting SQL or creating a complex object query :

 $users = pdoMap::get('users')->SelectBy('Name', 'john');
 if ($users->count()) {
  echo 'Hello '.$users->current()->Name;
 }

Example of a simplified XML which could be used in the above code:

<?xml version="1.0"?>
<table name="users">
 <fields>
  <field name="Id" type="Primary" />
  <field name="Name" type="Char" size="64" />
  <field name="Password" type="Char" size="32" />
 </fields>
 <adapter>
  <request name="Login" type="select">
   <params>
    <param name="name" />
    <param name="pwd" />
   </params>
   <where>
    <cond field="Name" equals="{name}" />
    <cond field="Password" equals="{pwd}" function="md5" />
   </where>
  </request>
 </adapter>
</table>

Example of how to call the login query as defined in the XML block above:

 $users = pdoMap::get('users')->Login('john', 'doe');
 if ($users->count()) {
  echo 'Hello '.$users->current()->Name;
 }

Features

  • Focus on database design by managing structure in XML
  • Mapping database tables with automatically generated classes from XML mapping files
  • Provides a RAD environment that allows to write queries in an XML syntax
  • Provides a programmatic SQL language compatible with all database engines
  • Extensible field types (by default : primary / foreign / char / text / boolean / int / float / date)
  • Provides deployment procedures and functionalities which create database and tables (including joints)
  • Creates a service oriented classes by overriding tables adapters.
  • Uses oriented event crud which enables interaction between the entities and advanced database logic.