开发者

How to find users based on groups defined in ACL in CakePHP?

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 wa开发者_如何转开发y of using $this->Model->find();?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜