Dingo Framework

Dingo is a Rapid Development Application Framework written in PHP. Dingo allows you to create dynamic changing websites easily and quickly.

Basic ORM

The Dingo database library provides the structure to easily implement very basic object-relational mapping in your applications. The first step to implementing ORM into your queries is simply adding a second argument to the db() function of your queries.

$data = db('table','contacts')->all();

This second argument tells Dingo to load the orm class located at application/orm/contacts.php and make each result returned by the query an instance of the contacts_orm class.

An ORM class for a contacts table containing the columns id, first_name, and last_name might look like this:

class contacts_orm
{
    public $id;
    public $first_name;
    public $last_name;
    
    public function full_name()
    {
        return $this->first_name.' '.$this->last_name;
    }
}

You could then use the custom method you placed in your ORM class:

foreach($data as $contact)
{
    echo $contact->full_name();
}

In this way, Dingo allows you to create your own ORM system for your application. The ORM Library may also be used to add additional functionality to ORM classes.

Note: If the PHP __construct() Magic Method is present in your ORM class, it will be loaded after any data is added to the instance by a database query. This allows you to use that data in the constructor.

© 2008 - 2010 Evan Byrne