Part of the EllisLab Network
   
1 of 57
1
IgnitedRecord 1.0 pre-release
Posted: 30 April 2008 10:11 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  727
Joined  08-03-2006

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

 Signature 

RapidDataMapper: My new ORM, is now released!

IgnitedRecord: Old ORM

MPTtree: A model to handle trees in a database.

YAYParser - Yet Another YAML Parser

Profile
 
 
Posted: 30 April 2008 10:17 AM   [ Ignore ]   [ # 1 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3185
Joined  06-10-2007

Good work man. Fantastic contribution wink

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

Profile
 
 
Posted: 30 April 2008 10:31 AM   [ Ignore ]   [ # 2 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4785
Joined  07-14-2006

I’ve read somewhere else you are making the orm library php4 compatible, is this the one?

Profile
 
 
Posted: 30 April 2008 10:37 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  727
Joined  08-03-2006

Yeah, this is the one.
But you have to comment the __call() methods in both the IgnitedRecord and IgnitedRecord_record classes.
By removing them you only remove the aggregation of behaviours and their helpers.

Example:

$page $this->page->get();
$page->get_children(); // with __call()
$page->tree->get_children(); // without

$about $this->page->xpath('/about/me'); // with __call()
$about $this->page->tree->xpath('/about/me'); // without 

As you see there is no great difference (using the tree behaviour tongue laugh).
Another thing a PHP 4 user might want to change is the ‘= new’ to ‘=& new’.

All that is covered in the manual.

 Signature 

RapidDataMapper: My new ORM, is now released!

IgnitedRecord: Old ORM

MPTtree: A model to handle trees in a database.

YAYParser - Yet Another YAML Parser

Profile
 
 
Posted: 30 April 2008 10:41 AM   [ Ignore ]   [ # 4 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4785
Joined  07-14-2006

Great, i’m going to check this out.

Profile
 
 
Posted: 01 May 2008 10:02 AM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  497
Joined  10-11-2007

Using this I’m given the following error if no records are returned:

A PHP Error was encountered
Severity: Notice
Message: Only variable references should be returned by reference
Filename: models/ignitedrecord.php
Line Number: 774

 Signature 

BarrettNewton.com
CartThrob.com

Profile
 
 
Posted: 01 May 2008 01:20 PM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  727
Joined  08-03-2006

Ok, thanks for the feedback, the error is fixed in the RC 3.

I have also managed to get my database to work under PHP 4 (couldn’t connect earlier), so I have done some testing and changes so it now works on PHP 4 without changes (I hope all references work as they should and that no more PHP 4 specific errors are present).

And finally I have fixed the hooks system, so passing by reference works for everything.

PS. I was wrong about the need to comment the __call() methods in PHP 4, it isn’t needed (manual is now changed)

 Signature 

RapidDataMapper: My new ORM, is now released!

IgnitedRecord: Old ORM

MPTtree: A model to handle trees in a database.

YAYParser - Yet Another YAML Parser

Profile
 
 
Posted: 01 May 2008 05:04 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  497
Joined  10-11-2007

RC 3 has a few errors related to the hooks feature.

The hook($name, $data) function requires 2 parameters, and in a few instances, you’re only passing the $name. I set $data=null in the function call… but I didn’t look deep enough to see if that’s going to cause me problems elswhere.

 Signature 

BarrettNewton.com
CartThrob.com

Profile
 
 
Posted: 01 May 2008 05:26 PM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  727
Joined  08-03-2006

You are right, a mistake by me (thanks for telling).
The $data parameter is passed to call_user_func_array(), so it should be:

function hook($name,$data = array()){
... 

I guess I concerned myself a bit too much with the passing of all references…

 Signature 

RapidDataMapper: My new ORM, is now released!

IgnitedRecord: Old ORM

MPTtree: A model to handle trees in a database.

YAYParser - Yet Another YAML Parser

Profile
 
 
Posted: 02 May 2008 01:19 AM   [ Ignore ]   [ # 9 ]  
Grad Student
Avatar
Rank
Total Posts:  61
Joined  03-02-2008

Wow, thanks for the great things here, It’s help me soooo much

 Signature 

Tarichi | Tarichi | Tarichi - Thanks to CI

Profile
 
 
Posted: 02 May 2008 07:20 AM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  11
Joined  02-13-2007

When I try to establish a new relationship between two models I get this error:

A PHP Error was encountered
Severity: Notice
Message: Undefined property: IgnitedRecord_record::$instance
Filename: models/ignitedrecord.php
Line Number: 1180

A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: models/ignitedrecord.php
Line Number: 1180

This what I’ve done:

$this->load->model("post");
$this->load->model("tag");
        
$rec $this->post->new_record();
$rec->title 'A new post';
$rec->slug    'a-new-post';
$rec->save();
        
$tag $this->tag->new_record();
$tag->name 'Blah';
$tag->save();
           
$post $this->post->find(2);
$tag $this->tag->find_by('name''Blah');
        
$post->add_relationship($tag); 

What am I doing wrong?

Profile
 
 
   
1 of 57
1
 
‹‹ It worked      Extension to the Table Class ››