DataMapper (Overzealous edition) and many-to-many with attribute
I'd 开发者_运维知识库like to create a relationship with an attribute using datamapper overzealous edition.
I have 2 main models: - Role (roles table) - Policy (policies table)
a role can have many policies and a policy can have many roles.
To do so I created a relationship table with role_id and policy_id. I also added to this table an attribute (named permission) that is a boolean value that indicate me if a specific policy in a specific role is allowed or not.
How can I write/update/read this value?
$role->policy->get();
gives me only all information inside policies table. Instead I'd like to have the informations inside policies table and of the relationship table.
Thanks for the help! :)
Don't know if you found the answer yet, but you can access the extra field(s) in a join table through the get_join_fields()
and set_join_fields()
methods. You can find more information in the documentation.
精彩评论