【发布时间】:2018-02-28 00:35:00
【问题描述】:
我正在尝试在我的 foreach 循环的 WHERE 中添加第二个条件。
$customers = Customers::find()->where(['status' => 1])->orderBy('vip DESC, id ASC')->all();
目前,我有过滤 where status=1 但我还需要添加 where 'rank' 不等于文本“Can”。
我需要 StackOverflow 的原因是我试图在网上找到答案,但是我有一个文本比较和一个我以前没有使用过的新查询方法,所以我不能很好地研究。
如何在 WHERE 子句 "AND 'rank' != 'Can' 中添加附加条件?
如果我不得不猜测它,我会这样写(这可能是错误的)
$customers = Customers::find()->where(['status' => 1])
->andwhere (['rank' !=> 'Can'])
->orderBy('vip DESC, id ASC')->all();
【问题讨论】:
标签: php activerecord yii