My favorites | Sign in
Project Logo
             
Code license: New BSD License
Labels: php, orm, activerecord, database
People details
Project owners:
  miketomasello

DataSourceORM

DataSourceORM is a object-relational mapping solution written in PHP and loosely based on the concept of delegation of database operations from the model to a datasource.

The term model is used here because DataSourceORM is really designed to be the 'Model' component in a 'Model View Controller' system. The components can be used elsewhere without issue, but this is its intended use.

Why DataSourceORM over alternatives like Doctrine or Propel?

Architectural reasons aside, the basic approach DSORM uses is different to solutions like Doctrine/Propel. DSORM can be considered a zero-configuration library. That's not entirely accurate, as you of course need to give your database connection details, but you do not need to define your schema in an XML or YAML file, or through any other method. This makes DSORM easier to use and more portable, but it does mean some advanced features are sacrificed as DSORM is unable to analyse the schema with class definitions.

Essentially, the advantages of DSORM are:

However, the disadvantages are:

Examples

Imagine the following table:

name (primary key) manufacturer colour type
MacBook Apple white notebook
MacBook Pro Apple silver notebook
Eee PC ASUS white netbook

Assuming the correct models were set-up, you could manipulate this dataset with the following code:

Retrieving Records

$appleMacBook = new Product('MacBook');

echo $appleMacBook->getColour(); // 'white'

$appleMacBook->setColour('black');
echo $appleMacBook->getColour(); // 'black'
$appleMacBook->save(); // this update is committed to the database with an UPDATE query

Creating Records

$macBookAir = new Product;
$macBookAir->setName('MacBook Air');
$macBookAir->setManufacturer('Apple');
$macBookAir->setColour('white');
$macBookAir->setType('subnotebook');
$macBookAir->save(); // this is committed using an INSERT query








Hosted by Google Code