How to exclude values ​​from a database query in Yii2. For example:

$User->find()->where(['<>', 'name', 'admin'])->all(); 

Exclude 'admin' from the 'name' column

But if all the same is written in the form of an array:

 $User->find()->where(['<>', 'name', ['admin', 'someUser']])->all(); 

An exception will already be raised.

    1 answer 1

    Found the answer in Of. documentation: http://www.yiiframework.com/doc-2.0/yii-db-queryinterface.html#where()-detail

    Instead of the '<>' operator, you can use the 'not in' operator, then the third argument can be an array:

     $User->find()->where(['not in', 'name', ['admin', 'someUser']])->all();