IgnitedRecord 1.0 pre-release |
[eluser]flojon[/eluser]
Suddenly I got this error. I don't know what I changed... Quote:Fatal error: Call to a member function find_all_by() on a non-object in /Users/flojon/Sites/anmalan.nu/system/application/models/IgnitedRecord/ignitedrecord.php on line 1414 but I think I found a fix for it. I think your test: Code: if(!in_array($data['model'],get_object_vars($CI))) Code: if(!isset($CI->$data['model']))
[eluser]Animas[/eluser]
I found another project "ActiveRecord Class Mod". Can you tell me the difference with this project? Which one will be easier and feature rich?
[eluser]m4rw3r[/eluser]
Well, by asking me you are asking for a biased opinion ![]() Things that differ (I may have missed a few features): - IgnitedRecord is fully PHP 4 compatible (except the aggregation of behaviours, but does not really count) - IgnitedRecord can use pure SQL - IgnitedRecord has a lot of hooks, so it is easier to implement addons/plugins/behaviours (see the Act As Timestamped plugin above) - IgnitedRecord has support of behaviours - IgnitedRecord assumes default values, but is configurable - ActiveRecord Class Mod enforces stricter naming conventions - ActiveRecord Class Mod has it's own SQL string builder (IR is using CI's AR, for now) - ActiveRecord Class Mod has JOINs built in (and easy to access, via functions, in IR you must write the SQL yourself)
[eluser]flojon[/eluser]
I get the following error when I try to restore an IgnitedRecord object from the $_SESSION array: Quote:The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "IgnitedRecord_record" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition Any thoughts on what to look for? At first I had forgot to load the model, but I get the same error even when I load the model. This is the code: Code: $this->load->model('registration'); Thanks! EDIT: Solved: One must load the model before session_start! Silly me... ;-)
[eluser]Hyra[/eluser]
Is there gonna be support for "order by" functionality? Code: $this->load->orm('Artworks', 'artworks'); works a charm, but the comments are ordered "randomly". It would be nice to be able to add something like Code: $comments = $artwork->get_related('ArtworkComments')->order_by('CommentID', 'DESC');
[eluser]m4rw3r[/eluser]
Oh, that is something I'll look into. I'm currently redesigning the whole relationship part of IgnitedRecord (one third of the code, which is annoying, but I can see how it will improve IgnitedRecord), because of the bug with auto finding models. So I hope I can implement it. (and to all others out there having suggestions for the relation part of IgnitedRecord, go ahead and make suggestions while I'm redesigning it!)
[eluser]flojon[/eluser]
I don't know if it's related to relatationships but I have a change I would like. I'm implementing validation as a behaviour and there needs to be some changes in the IgnitedRecord class for this to work. The hooks (or at least the save_pre_strip_data hook that I'm using) needs to be able to abort the current operation. So in my case if the hook return false, the save operation will abort. I've realized that this has implications on the rest of the code since save is called in few places and doesn't look at the return value. I made the following "hack" to make it work but maybe you could have this in mind if you're doing such a large rework anyway. Code: function hook($name,$data = array()){ Thank you for your superb work! Regards, Jonas
[eluser]sophistry[/eluser]
EDIT: OOPS! um... sorry! scratch that comment about PHP5 everyone. i was looking in the wrong place in the PHP manual. those functions are PHP4 compatible. since you asked for feedback :-) ... the 012 trunk has two Magic functions that are PHP5 only ( namely, __sleep() and __wakeup() ). are you dropping support for PHP4 in the next release? thanks! (stuck on 4 for now).
[eluser]m4rw3r[/eluser]
@flojon I realize how useful it is for a behaviour to be able to abort save (and delete, perhaps?), so I will apply your patch (thanks!). @sophistry Glad you found Classes and Objects (PHP 4) - The magic functions __sleep and __wakeup, they are sometimes a bit messy, those docs ![]()
[eluser]Hyra[/eluser]
Again, great work! I tried the package in my current site to see how it would work, and it does just that: work ![]() But for more complicated tasks it seems I will either have to extend the IgnitedRecord model, which would make upgrading it in case of a new version not so pleasent or I will have to find a way to extend the derived classes for added functionality. But maybe I'm just not seeing something. How would one go about the following. Tables: Users Has the simple data from the regged users such as a name and location. Posts Contains the posts made by the users, foreign keyed with a UserID in the table. Comments Contains the comments made on the posts, foreign keyed with a PostID and UserID in the table. The User class would look something like Code: class Users extends IgnitedRecord { The Post class Code: class Posts extends IgnitedRecord { and finally, the comments Code: class Comments extends IgnitedRecord { How would you show a list of a certain post with all its comments where the comments show the User names as well? Code: // Retrieve the data of the post Would one have to loop through all the comments in a foreach and retrieve the username by doing? Code: $comments[i]->UserName = $this->users->find($comments[i]->UserID); As that seems server intensive, and as the fields grow (location, etc.) it would become tedious. Especially if you use it on more than one page (unless you store it in a subroutine somewhere, making the code less "watchable" Anyway, like i said, maybe I just missed a line in your manual. Which is great btw. |
Welcome Guest, Not a member yet? Register Sign In |