我一直在想我的问题到底出了什么问题,这应该很简单。更像是我在创建一个select*from表,其中(a=1和b=2)或(a=2和b=1)类型的查询。这是我的口才。
return $query->where(function($q) use ($brand, $influencer, $agency){
$q->where([
'sender_id' => $brand,
'receiver_id' => $influencer
]);
$q->orWhere([
'sender_id' => $influencer,
'receiver_id' => $brand
]);
});
我有这个问题在我的雄辩,但当显示在调试栏它的显示
select count(*) as aggregate
from `chat_messages`
where ((`sender_id` = '415' and `receiver_id` = '1159')
or (`sender_id` = '1159' or `receiver_id` = '415'))
我希望它在第二个括号里是“and”
select count(*) as aggregate
from `chat_messages`
where ((`sender_id` = '415' and `receiver_id` = '1159')
or (`sender_id` = '1159' AND `receiver_id` = '415'))
1条答案
按热度按时间az31mfrm1#
如果你打电话
orWhere()
对于数组,它使用OR
在前面和各个约束之间。使用此选项: