thinkphp5.1 数据库查询多条件时使用索引数组并含有or的查询
如题,我希望的查询是这样的
SELECT * FROM `bus_product` WHERE name like '%keyword%' and ( `department_id` = 6 or `department_id` IS NULL )
使用索引数组查询时,只需要这样设置
$map[] = ['no|name|season|remark', 'like', "%{$data['keyword']}%"]; //这里是重点 $map[] = ['department_id',['eq',$this->user->department],['null',''] , 'or'];
就能够达到要求啦!