$data = $this->request->post(); $where = []; $where['status'] = 1; $map['name'] = ['like','%'.$data['goods_name'].'%']; $goods_list = Db::name('mall_goods')->where($map)->order($order)->select();
查询报错。。。打印sql语句发现是这样的:
"SELECT * FROM `tp_mall_goods` WHERE `status` = 1 AND `name` IN ('like','%发%')"
tp5 是支持这样查询的,下面是tp5同样的sql语句:
"SELECT * FROM `tp_mall_goods` WHERE `status` = 1 AND `name` LIKE '%发%'"
殘留の回憶2019-06-27 22:34:35
thinkphp5是这样的吧,where('name', 'like', 'php')-
数组的形式是这们的,$where['name'] =array('like',array('%1%','%2%'),'OR')