Laravel 4雄辩的OR OR OR? [英] Laravel 4 eloquent WHERE with OR AND OR?
本文介绍了Laravel 4雄辩的OR OR OR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何说 WHERE(a = 1 OR b = 1)AND(c = 1 OR d = 1)
对于更复杂的查询,我应该使用原始SQL?
For more complicated queries am I supposed to use raw SQL?
推荐答案
使用参数分组( Laravel 4.2 )。例如,它将是这样的:
Make use of Parameter Grouping (Laravel 4.2). For your example, it'd be something like this:
Model::where(function ($query) {
$query->where('a', '=', 1)
->orWhere('b', '=', 1);
})->where(function ($query) {
$query->where('c', '=', 1)
->orWhere('d', '=', 1);
});
这篇关于Laravel 4雄辩的OR OR OR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文