IgnitedRecord 1.0 pre-release - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: IgnitedRecord 1.0 pre-release (/showthread.php?tid=7996) |
IgnitedRecord 1.0 pre-release - El Forum - 05-02-2008 [eluser]Andre83[/eluser] 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: Code: $this->load->model("post"); What am I doing wrong? IgnitedRecord 1.0 pre-release - El Forum - 05-02-2008 [eluser]m4rw3r[/eluser] Whoops, I forgot the double underscore before the instance property (had started to move some methods from MPTtree ORM to IgnitedRecord, so I guess I forgot them (MPTtree uses only instance, without underscores)). Updated the errata. Thanks! IgnitedRecord 1.0 pre-release - El Forum - 05-02-2008 [eluser]Andre83[/eluser] Thanks for the fix, m4rw3r; for some reason the following is not working though. Code: $post->add_relationship($tag); I would expect it to create a new record in the posts_tags table, but it doesn't. Edit: sorry, my fault, all's working wonderfully now IgnitedRecord 1.0 pre-release - El Forum - 05-02-2008 [eluser]m4rw3r[/eluser] Have you defined a has and belongs to many relationship between the two models (it is needed at least for the object where you are calling add_relationship())? Because it is working fine for me... Code: // here is the relationship needed, because you establish a relation from a child record of this class EDIT: Didn't see that you cleared that up IgnitedRecord 1.0 pre-release - El Forum - 05-02-2008 [eluser]Andre83[/eluser] Okay I've got another problem for you to solve I'm trying to delete a record from the database, and see if also the corresponding relationships are deleted too, so I write this: Code: $post = $this->post->find(2); I get this error: Message: Invalid argument supplied for foreach() Filename: models/ignitedrecord.php Line Number: 933 IgnitedRecord 1.0 pre-release - El Forum - 05-02-2008 [eluser]m4rw3r[/eluser] Could you post your derived class? Because everything works fine for me (the delete() method loops all relations and deletes them, so it is something with the relation properties). IgnitedRecord 1.0 pre-release - El Forum - 05-02-2008 [eluser]Andre83[/eluser] Code: class Post extends IgnitedRecord { Nothing more than this... IgnitedRecord 1.0 pre-release - El Forum - 05-02-2008 [eluser]m4rw3r[/eluser] Ok, this problem arises when a record which hasn't loaded any relations is being deleted. The __relation_properties in the IgnitedRecord_record class must be set to array() in the declaration. Updating the errata. Anyway, please give me more feedback (not only error reports, but error reports are fine I guess (then I have something to do, and I know that I've not wasted my time ))! IgnitedRecord 1.0 pre-release - El Forum - 05-02-2008 [eluser]Chris Newton[/eluser] Just FYI, I've had to move on from attempting to use this at the moment, so I won't be posting any additional comments at least for the near future. It shows promise, so I'll probably take a look again in a few weeks. Thanks for the efforts thusfar. IgnitedRecord 1.0 pre-release - El Forum - 05-03-2008 [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'), Code: var $has_one = array(array('table' => 'tablename', 'name' => 'relationname', 'col' => 'foreign_key'), Example: Code: class thread extends IgnitedRecord{ 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! |