0
votes

I'm using CakePHP here. Let's say I have 3 groups of user, namely:

  1. Super Admin
  2. Admin
  3. Customer

and this scenario has been setup using ACL.

Now, how do I return only users that belong to a particular group? e.g. Find all Customer only

I am able to do this using pure SQL statement:

SELECT *
FROM `users`
WHERE `id`
IN (
SELECT foreign_key
FROM `aros`
WHERE `parent_id` =3
)

How do I do it in CakePHP way of using $this->Model->find();?

1

1 Answers

0
votes

The way is the same as in all find cases:

$users = $this->User->find('all', array('conditions'=>array('User.aro_id'=>3)));

Basically it depends from the relation, but as far I understand it's Group hasMany Users.