TP5混合查询 and or 联合查询写法
2020-08-06 本文已影响0人
衡阿大
想要执行的SQL语句为
SELECT * FROM `aj_land` WHERE `land_no` = '0' AND ( `custom_name` LIKE '%4%' OR `custom_phone` LIKE
'%4%' ) AND `custom_id` = 0 LIMIT 1
tp5查询写法为
$where['land_no'] = 0;
if ($post['keyword']) {
$where['custom_name|custom_phone'] = ['like', "%" . $post['keyword'] . '%'];
}
$where['custom_id'] = 0;
$num = db('land')->where($where)->select();