$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')