laravel orwhere 导致where失效的问题

mysql 查询条件同时出现 or 和 and
将 或 运算的,用括号括起来。

//错误代码
select * from student where home='江苏省' or home='浙江省' and age='20';
//正确代码
select * from student where (home='江苏省' or home='浙江省') and age='20';

在laravel同一张表的链式操作中 orwhere导致where失效的问题

解决办法:使orwhere形成一个闭包的环境

原文地址:https://www.cnblogs.com/caibaotimes/p/14027907.html