[eluser]Basketcasesoftware[/eluser]
Code:
$modules = new Modules();
$modules->where_related("groups/permissions",...
And at the "..." is where I get stuck because you name the tables but don't give their structure.
But what you are looking for in the DataMapper User Guide is Get (Advanced) under the head Deep Relationship Queries.
Your example uses a framework where the tables have foreign keys.
[quote author="Robert Liljedahl" date="1297368772"]I'm stuck on howto make a query.
I got groups, permissions and modules. I'm working on the update-function in the groups-controller.
I want to list all the modules and show if the group do in fact have access to the module in question.
It's easy for me to get all modules. It's also easy for me to get all permissions for a certain group.
The question is how I combine these two into on query for DataMapper.
This is how I'd do it with a 'normal' query:
Code:
SELECT modules.*, permissions.id AS 'permission_id'
FROM modules
LEFT OUTER JOIN permissions
ON (permissions.module_id = modules.id AND permissions.group_id = 4)
GROUP BY modules.id
[/quote]