普通 php 中的查询是
$p = "SELECT * FROM followusers WHERE (follower='$followed1 and
followed='$follower1') or (follower='$follower1' and
followed='$followed1')"
我在 yii2 中编写的查询是
$y = Followusers::find()->where(['follower' => $userid ] and
['followed' => $conid])->orwhere(['followed' => $userid ] and
['follower' => $conid])-> all();
但我没有得到 yii2 中查询所需的结果
最佳答案
试试这个方法:
Followusers::find()->where(['follower' => $userid])
->andWhere(['followed' => $conid])
->orwhere(['AND',
['followed' => $userid],
['follower' => $conid]
])
-> all();
关于php - 在 yii2 中编写具有多个 where 条件的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38281591/