views:

260

answers:

1

In the auth module, we have users and roles with a many to many relationship.

My question probably has a simple answer, but I couldn't find it by myself... How would I go about selecting only users having a certain role using ORM? What I'd like to do is something like this:

ORM::factory('user')->with('roles')->where('role','member')->find_all();

but that does not work...

Thank you

+1  A: 

You want to do this:

$members = ORM::factory('role', 'member')->users;

You take the role and find it's users, not the other way around.

zombor
aha! Thank you very much indeed!
jfoucher