1

This is the controller action list which should display users in a user table if a user role is not super

 public function actionList()
{
    $dataProvider = new ActiveDataProvider([
        'query'=>User::find()->where(['not', 'is_super']),
        'pagination' => [
            'pageSize' => 20,
        ],
    ]);

    return $this->render('list', ['dataProvider'=>$dataProvider]);
}

What could be the problem

10
  • 1
    What is not? Is it column name? Commented Jul 14, 2016 at 10:11
  • And, if no. Then, provide column name. Commented Jul 14, 2016 at 10:12
  • No it means find where a user is not a super user Commented Jul 14, 2016 at 10:12
  • So, what is that column name where all values are being saved. Like: is_super, is_no_super. There will be column name Right, where all values are being stored? Commented Jul 14, 2016 at 10:13
  • The column name is is_super Commented Jul 14, 2016 at 10:15

2 Answers 2

1

Change your query to

'query' => User::find()->where(['<>','is_super',1]),

Or,

<?php
$super = 1; 
$dataProvider = new ActiveDataProvider([
  'query' => User::find()->where(['<>','is_super',$super]),
  'pagination' => [
      'pageSize' => 20,
  ],
]);
?>
Sign up to request clarification or add additional context in comments.

2 Comments

Still returns an error of ...[Only variables should be passed by reference]
Try, $super=1; 'query' => User::find()->where(['<>','is_super',$super]), @GEOFFREYMWANGI
1

Try:

'query' => User::find()->where('is_super<>:is_super',[':is_super' => 1]),

1 Comment

Thanks works, but the first answer above worked ...thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.