![]() |
DataMapper ORM v1.8.1 - 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: DataMapper ORM v1.8.1 (/showthread.php?tid=42440) |
DataMapper ORM v1.8.1 - El Forum - 06-27-2011 [eluser]WanWizard[/eluser] @Spelljack, Thanks, I saw the pull request. I'll try to find some time later this week to have a look and run some tests... DataMapper ORM v1.8.1 - El Forum - 06-30-2011 [eluser]Nicolas L.A.[/eluser] Hi WanWizard, I'm brand new on CI and I wanted to be able to easily manipulate the models relationship as I use to do with cakePHP and your solution seems perfect. Reminds me a lot of models in cake. I still have a question related to Many-To-Many relation. Let's say table A has many A_B and B has many A_B. How could I retrieve and declare a field in A_B table? Cheers, DataMapper ORM v1.8.1 - El Forum - 06-30-2011 [eluser]WanWizard[/eluser] What do you mean by A_B? In Datamapper, if you have a many-to-many relation between A and B, you'll have a model A and a model B, with a table As, Bs, and a table As_Bs which contains the id's of both A and B and allow the many-to-many to exist. If you have data that is relevant to the relationship between A and B, and therefore has to be stored in the relationship table As_Bs, you'll use the join_fields() methods of Datamapper. DataMapper ORM v1.8.1 - El Forum - 06-30-2011 [eluser]Nicolas L.A.[/eluser] [quote author="WanWizard" date="1309453191"]What do you mean by A_B? In Datamapper, if you have a many-to-many relation between A and B, you'll have a model A and a model B, with a table As, Bs, and a table As_Bs which contains the id's of both A and B and allow the many-to-many to exist. If you have data that is relevant to the relationship between A and B, and therefore has to be stored in the relationship table As_Bs, you'll use the join_fields() methods of Datamapper.[/quote] I meant As_Bs obviously as you understood it. I'm obviously not talking about the *_id fields but rather about an extra field in the As_Bs table which is not link to any other table. Like : Code: .-------------. Would this method join_fields() work for this? Thanks DataMapper ORM v1.8.1 - El Forum - 06-30-2011 [eluser]WanWizard[/eluser] Yes, that is exactly what I mean. See http://datamapper.wanwizard.eu/pages/joinfields.html. DataMapper ORM v1.8.1 - El Forum - 06-30-2011 [eluser]Nicolas L.A.[/eluser] [quote author="WanWizard" date="1309460126"]Yes, that is exactly what I mean. See http://datamapper.wanwizard.eu/pages/joinfields.html.[/quote] Thank you. Despite reading your user guide I didn't find this page. I was expecting the information in the "General Topics > Setting up Relationships" page rather than the current separate one under "Relationships > Working with Join Fields". DataMapper ORM v1.8.1 - El Forum - 06-30-2011 [eluser]Spelljack[/eluser] @WanWizard I am in a terrible situation. I need to generate this Query with DataMapper. Could you help me? It's very complicated and I couldn't find a way. I changed the tables below like this: 'aroes', 'aro_groups', 'aroes_aro_groups' So as you see aroes and aro_groups has many-to-many relationship. Code: SELECT DataMapper ORM v1.8.1 - El Forum - 06-30-2011 [eluser]WanWizard[/eluser] That looks very much like some sort of nestedset implementation (get all parents of). Is this existing code/data, or are you building something new? If so, you might want to look at the nestedsets extension, which does all this for you (and more). DataMapper ORM v1.8.1 - El Forum - 06-30-2011 [eluser]Spelljack[/eluser] I am trying to re-code phpGACL for CodeIgniter. This query gets the group id and its parent all the way up to root. DataMapper ORM v1.8.1 - El Forum - 07-04-2011 [eluser]Nicolas L.A.[/eluser] Is there a way to have the Nested Set plugin to return a structured array? I tried to use the dump_tree() function without success as it returns all the nodes on the same level. I am looking for something which would return something like the following: Code: array( Is that possible directly with your DM or do I have to code a recursive function to do so? Thanks. |