Search code examples
phpcakephp-2.9

Trying to display a user with the specific role in cakephp 2x


I am trying to display table Users, and I want it to display the user with the role "Moderator" only.

public function moderators() {

    $this->set('users', $this->paginate());
    $this->User->find('all', array(
    'conditions' => array('User.role' => 'moderator')
)); 

This is my controller, and it seems that it is still displaying all data in my table.


Solution

  • Try to use custom query for that:

    $this->User->query("select * from users where role = 'moderator';");