DataMapper 1.6.0 - 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 1.6.0 (/showthread.php?tid=11358) Pages:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
DataMapper 1.6.0 - El Forum - 03-10-2009 [eluser]OverZealous[/eluser] Neither the updated version of DM nor DM itself currently support information associated with the join table, which I have to assume is what you want. Right now, the closest you can get is to create a dedicated "relationship object", as I think of them, that contains the two objects and the extra relationship info. I use this to connect Contacts with other Contacts, for example (like Company/Employee): Code: class ContactRelationship extends DataMapper { Table: Code: contactrelationship Usage: Code: $contact = new Contact(); I can't provide too much more help than that. Alternatively, you might have to rethink your design. Maybe you can use a dedicated model to keep track of more general permissions (which is how I do it). It depends on your needs. I've actually been thinking about how to implement join table parameters for a while, but it always ends up making everything really complicated. DataMapper 1.6.0 - El Forum - 03-10-2009 [eluser]tdktank59[/eluser] NO no no lol... Not what i ment... each of the word/word were the permissions... heres the structure lol Users -> join_roles_users -> roles -> join_permissions_roles -> permissions -> page and method where the only one not having a join_ table is permissions having id page_id method_id otherwise the rest are joined together DataMapper 1.6.0 - El Forum - 03-10-2009 [eluser]OverZealous[/eluser] You are going to have to take a moment and ask a clearer question. In fact, you haven't actually asked a question yet DataMapper 1.6.0 - El Forum - 03-10-2009 [eluser]tdktank59[/eluser] Same question as before... How to save multiple relations of the same type... So i have these tables: Quote:<b>Roles</b> what im trying to do is set multipe permissions to 1 role. So for example Quote:p_id is permission_id just shorted and r_id is role_id How do I save multiple relations of the same type (permissions onto roles) in this case... The demo covers saving multiple with different classes heres the code Code: /** DataMapper 1.6.0 - El Forum - 03-10-2009 [eluser]OverZealous[/eluser] Are you just asking how to save a one-to-many relationship? I mean, that's what it looks like to me. I thought that was covered. You just do a ->save($obj) on each one, or ->save($array_of_obj) to save them all at once. You can also do ->save($obj->all) if $obj contains the result of a query. ->save($object) just saves a relation to $object. If the relationship is a has_many, it just adds it if the relationship doesn't already exist. If it is has_one, it replaces any existing relationship. My extended DM doesn't change this, except it allows for no join table on the has_one side of relationships. DataMapper 1.6.0 - El Forum - 03-10-2009 [eluser]tdktank59[/eluser] ok guess i didnt read the manual right then. DataMapper 1.6.0 - El Forum - 03-10-2009 [eluser]OverZealous[/eluser] http://stensi.com/datamapper/pages/save.html]Save: DataMapper User Guide - scroll down about halfway to Save Multiple Relations. It shows the ->all method of saving. DataMapper 1.6.0 - El Forum - 03-11-2009 [eluser]dmyers[/eluser] Any way to combine the active record "sql" builder into the datamapper object? You can do this in Datamapper and "push" a raw sql query into a datamapper object Code: $sql = "SELECT * FROM `users` WHERE `username` = 'Fred Smith' AND `status` = 'active'"; and you can do this to dynamically build a sql statement using the built in Active Records Code: $query = $this->db->get('auth_user'); but can you jam the active record "builder" into the datamapper object? DataMapper 1.6.0 - El Forum - 03-11-2009 [eluser]OverZealous[/eluser] I don't know what you are asking, but DataMapper just uses ActiveRecord internally. Calling $this->db->anything or $obj->db->anything modifies the ActiveRecord query just as it normally would. Then calling $obj->get() will process the results. DataMapper 1.6.0 - El Forum - 03-13-2009 [eluser]Roobiz[/eluser] Hi guys, I have a little problem with DM and count's method. My tables: b_messages -id -is_view -created -updated -ip b_topics -id -id_user_from -id_user_to -created -updated -title b_messages_b_topics -id -b_message_id -b_topic_id I Want to count all the non viewed messages linked to my topic (where my id == to id_user_from or id_user_to. I test this kind of query but without any success: Code: $btopic = new B_topic(); Can anyone help me? |