试图在cakephp 2x中显示具有特定角色的用户

时间:2017-05-09 04:30:19

标签: php cakephp-2.9

我正在尝试显示表用户,我希望它显示具有角色"主持人"仅

public function moderators() {

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

这是我的控制器,它似乎仍在我的表格中显示所有数据。

1 个答案:

答案 0 :(得分:1)

尝试使用自定义查询:

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