search

Home  >  Q&A  >  body text

tp6.0 query statement becomes like this? ?

$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 '%发%'"

文2024 days ago1288

reply all(1)I'll reply

  • 殘留の回憶

    殘留の回憶2019-06-27 22:34:35

    thinkphp5 is like this, where('name', 'like', 'php')-

    The form of the array is this, $where['name'] =array('like ',array('%1%','%2%'),'OR')

    reply
    0
  • Cancelreply