$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();
Query error. . . Print the sql statement and find that it is like this:
"SELECT * FROM `tp_mall_goods` WHERE `status` = 1 AND `name` IN ('like','%发%')"
tp5 supports such query. The following is the same sql statement for tp5:
"SELECT * FROM `tp_mall_goods` WHERE `status` = 1 AND `name` LIKE '%发%'"
thinkphp5 is like this, where('name', 'like', 'php')-
The form of the array is this, $where['name'] =array('like ',array('%1%','%2%'),'OR')