Laravel 5.1中带有AND OR的WHERE子句? [英] WHERE clause with AND OR in Laravel 5.1?
本文介绍了Laravel 5.1中带有AND OR的WHERE子句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将Laravel 5.1中的Where子句与or或or条件一起使用, 这是我的要求:
i am trying to use Where clause in Laravel 5.1 with or And or conditions, here is my requirement:
->WHERE (request_id=1) and (sender_id=11 or receiver_id=11)
如何在Laravel 5中使用上述子句.
how to use the above clause in Laravel 5.
您的帮助将不胜感激:)
Your help would be really appreciated :)
推荐答案
DB::table('yourTable')
->where('request_id', '=', '1')
->where(function($query)
{
$query->where('sender_id', '=', 11)
->orWhere('receiver_id', '=', '11');
})
->get();
这篇关于Laravel 5.1中带有AND OR的WHERE子句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文