-
Notifications
You must be signed in to change notification settings - Fork 0
IgnitedRecord
IgnitedRecord is a relation handling ORM[1] library, made for the PHP framework CodeIgniter.
The goal of IgnitedRecord is to provide an easy to use, easily customizeable, ORM library to CodeIgniter.
IgnitedRecord is designed with the factory pattern in mind and the models themselves does not contain the data.
Instead, they handle all the interaction with the database and provide the methods for fetching record objects from the database.
The record objects contain a reference to the object which created them, thus getting the ability to interact with the database.
So instead of creating new instances of the model, as you do in normal ActiveRecord[2], you ask the model to instantiate the records.
It's more like the DataMapper[3] pattern, where the record objects have no awareness of the underlying database. Instead they ask a mapper (in IgnitedRecord, the model is the mapper) to fetch, save and update data.
- Easily configurable
- Uses default values if settings are not explicitly set
- Relations: Belongs to Has Many Has One Has And Belongs To Many (shorted to habtm)
- When fetching related objects, it is possible to filter, order and modify the query in a large quantity of ways
- Belongs To and Has One relations can be fetched easily through a JOIN with the help of join_related()
- Behaviours, which can add and modify the functionality of IgnitedRecord
- Hooks and triggers where you can put your own code
- Complete support for PHP 4, no "hacks" or anyting else is required for IgintedRecord to work under PHP 4.
- Method Chaining under PHP 5
- Nested WHERE statements and subqueries, with help from IgnitedQuery
- Partial support for multiple primary keys (relations are not supported, yet)
$this->load->model('ignitedrecord/ignitedrecord');
$this->post = IgnitedRecord::factory('posts');
$this->post->belongs_to('user')->fk('author');
$posts = $this->post->like('title', 'CodeIgniter')
->order_by('date', 'desc')
->join_related('user')
->find_all();
foreach($posts as $post){
echo $post->title;
echo $post->user_username;
}
You can download it in a prepackaged zip from Assembla here. Or you can download the latest version via svn at this url: http://svn.assembla.com/svn/IgnitedRecord/trunk .
The Assembla space for IgnitedRecord or The thread about IgnitedRecord at CodeIgniter's forum
[1] Object Relational Mapping, See Wikipedia about Object Relational Mapping
[2] A pattern for Object Relational Mapping, See Wikipedia about ActiveRecord
[3] Another pattern for Object Relational Mapping, See An abbrevated text from Patterns of Enterprise Application Architecture
Category:Contributions::Libraries::Database Category:Libraries::Database