DataMapper 1.6.0 |
[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.
[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
[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 ![]()
[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: /**
[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.
[eluser]OverZealous[/eluser]
http://stensi.com/datamapper/pages/save....User Guide - scroll down about halfway to Save Multiple Relations. It shows the ->all method of saving.
[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?
[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.
[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? |
Welcome Guest, Not a member yet? Register Sign In |