• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IgnitedRecord 1.0 pre-release

#1
[eluser]m4rw3r[/eluser]
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

Code:
$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

#2
[eluser]wiredesignz[/eluser]
Good work man. Fantastic contribution Wink

#3
[eluser]xwero[/eluser]
I've read somewhere else you are making the orm library php4 compatible, is this the one?

#4
[eluser]m4rw3r[/eluser]
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:
Code:
$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 :-P).
Another thing a PHP 4 user might want to change is the '= new' to '=& new'.

All that is covered in the manual.

#5
[eluser]xwero[/eluser]
Great, i'm going to check this out.

#6
[eluser]Chris Newton[/eluser]
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

#7
[eluser]m4rw3r[/eluser]
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)

#8
[eluser]Chris Newton[/eluser]
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.

#9
[eluser]m4rw3r[/eluser]
You are right, a mistake by me (thanks for telling).
The $data parameter is passed to call_user_func_array(), so it should be:
Code:
function hook($name,$data = array()){
...

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

#10
[eluser]srobet[/eluser]
Wow, thanks for the great things here, It's help me soooo much


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.