Php 在WHERE子句中添加第二个条件?

Php 在WHERE子句中添加第二个条件?,php,activerecord,yii,Php,Activerecord,Yii,我试图在foreach循环的WHERE中添加第二个条件 $customers = Customers::find()->where(['status' => 1])->orderBy('vip DESC, id ASC')->all(); 目前,我对status=1的地方进行了过滤,但我还需要添加“rank”不等于文本“Can”的地方 我需要StackOverflow的原因是我试图在网上找到答案,但我有一个文本比较和一个新的查询方法,我以前没有使用过,所以我不能很好地研

我试图在foreach循环的WHERE中添加第二个条件

$customers = Customers::find()->where(['status' => 1])->orderBy('vip DESC, id ASC')->all();
目前,我对status=1的地方进行了过滤,但我还需要添加“rank”不等于文本“Can”的地方

我需要StackOverflow的原因是我试图在网上找到答案,但我有一个文本比较和一个新的查询方法,我以前没有使用过,所以我不能很好地研究

如何在WHERE子句“和'rank'!='Can'中添加附加条件

如果要我猜的话,我会这样写(这可能是错的)


依我看你需要换车,去哪里,去哪里。 或者试试这个

$customers = Customers::find()->where("status = 1 and rank!='Can'"])->orderBy('vip DESC, id ASC')->all();
根据惊奇的说法,您必须使用
和where()
方法:

$customers = Customers::find()->where(['status' => 1])
   ->andwhere (['not', ['rank' => 'Can']])
   ->orderBy('vip DESC, id ASC')->all();
或:

->andwhere(['''rank','Can'])
请记住,
PHP
没有比较运算符

$customers = Customers::find()->where(['status' => 1])
   ->andwhere (['not', ['rank' => 'Can']])
   ->orderBy('vip DESC, id ASC')->all();
->andwhere (['<>', 'rank', 'Can'])