jfoucher
jfoucher

Reputation: 2281

Select users with a certain role in Kohana's auth module

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

Upvotes: 0

Views: 1776

Answers (1)

zombor
zombor

Reputation: 3257

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.

Upvotes: 1

Related Questions