![]() |
Datamapper deep relationships - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Datamapper deep relationships (/showthread.php?tid=54915) |
Datamapper deep relationships - El Forum - 10-01-2012 [eluser]bralens[/eluser] Hello, i have problem with deep relations. My post model Code: var $has_one = array( And i need to get all brothers and sisters (parent/childrens), but when i do Code: $this i get this error Code: Cannot use object of type Post as array in datamapper/libraries/Datamapper.php on line 2739 odd, but Code: $this feels like datamaper works backwards... Datamapper deep relationships - El Forum - 10-01-2012 [eluser]WanWizard[/eluser] I can't comment on that. This shows a model called "Post" which has a "has_one" to "parent" and a "has_many" to "childrens". It doesn't show the relations between "parent" and "childrens", which is what is used when you specify "parent/childrens". Second point is that in a relationship definition, "class" points the the model class the relationship is pointing to. Which in this example is the "Post" model itself? Datamapper deep relationships - El Forum - 10-02-2012 [eluser]bralens[/eluser] Ok, i forgot to mention that it is self-relationship and in future i will need alot of that kind of self-relationships. First i throught of join fields (but there will be multiple differnet self-relationships with the same posts and i don't think that join fields is best for that) Than i found "Multiple Relationships to the Same Model" in datamapper docs. There is example with creator and editor. I need that but to be self relationship. So what you recommend me to do and how? Datamapper deep relationships - El Forum - 10-02-2012 [eluser]WanWizard[/eluser] Self relationships are documented under "Advanced relationships". The example is many-to-many, but one-to-many is defined in exactly the same way, but then without the relationship table. Take care how you name the FK (the join_self and join_other values). |