[eluser]m4rw3r[/eluser]
IgnitedRecord have now been updated to 0.1.0 RC 4
I have now made some changes on how the more "advanced" relations (not using all defaults) are defined:
previous:
Code:
var $has_one = array('tablename' => array('name' => 'relationname', 'col' => 'foreign_key'),
'tablename2' => array('name' => 'rel2')
);
the new way:
Code:
var $has_one = array(array('table' => 'tablename', 'name' => 'relationname', 'col' => 'foreign_key'),
array('table' => 'tablename', 'name' => 'another_to_same')
);
Personally I think the new version is more descriptive, and it adds a new feature: Now you can relate to the same table with different relationnames using the same relation type.
Example:
Code:
class thread extends IgnitedRecord{
var $has_many = array(array('table' => 'posts', 'col' => 'thread_id'),
array('table' => 'posts', 'col' => 'thread_id_comment', 'name' => 'comments')
);
}
In the model above, we have both comments and posts stored in the same table. If a post is only a comment, it has only the thread_id_comment set, if it is a post it has thread_id set, and if it is both it has both set.
Some bugs have been corrected and loading of relations now logs a warning if no relation with that name was found.
I've also added calls to show_error() in the __call() methods if no method is found.
I'm currently playing around with JOINs and aliases, and if somebody wants to help I'd be grateful. It seems like IgnitedRecord would loose a lot of flexibility when fetching objects if I implement the JOINs like my current experimentations suggests, so I will probably make join variants of most of the existing methods for fetching data.
If anyone have a suggestion on how to implement JOINs, please share.
Thanks for your feedback!