IgnitedRecord is a relation handling ORM library, reminding a bit of Ruby on Rails’ ActiveRecord implementation.
The goal of IgnitedRecord is to provide an easy to use, easily customizeable, ORM library to CodeIgniter.
Current version: 0.2.0
(pre-release exists, missing a few features: “through” relations, finished form generation, remade and updated manual)
Features
- 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)
- Almost as fast as native CI ActiveRecord when using simple queries, faster when using more complicated ones!
- 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)
- A CodeIgniter-style manual, which covers almost all aspects of IgnitedRecord
Benefits
- Repetitious work is minimized.
- You have a finished model base to builld on.
- You don’t have to write SQL if you don’t want to.
- The choice between updates and inserts is automatically determined.
- The result resources are automatically cleaned up, to improve speed and lower memory consumption.
- The code is easier to read
Performance
Compared to CodeIgniter’s ActiveRecord
-1 % to over 200 % speed gain!!
Compared to direct db interaction
-11 % to -3 %
When performing simple queries, it is almost as fast as Ci’s AR, but when performing more advanced queries it is a lot faster than AR.
Example
$this->load->model('ignitedrecord/ignitedrecord');
$this->post = IgnitedRecord::factory('posts');
$this->post->belongs_to('user')->fk('author');
$posts = $this->post->like('CodeIgniter')
->order_by('date', 'desc')
->join_related('user')
->find_all();
foreach($posts as $post){
echo $post->title;
echo $post->user_username;
}
Screencast with the 1.0-dev: here
Wiki page: CI Wiki
Download: Assembla SVN Browser (possible to download a zip with a link in the right corner)
Assembla project space: IgnitedRecord