thinkphp中where里的like模糊查询为空解决办法
2023-03-29 23:03:03
344
{{single.collect_count}}

例子:

public function test(){$this->model->where($where)->select();}
  1. 看过网上的like模糊教程,如下写法查询为空:
where['name'] = ['like','%'.'c'.'%']
  1. 在请教他人后得到正确写法:
where[] = ['name','like','%'.'c'.'%']
  1. 之前自己也试过这种写法,但是报错了,原因是在它之前有其他的查询(如 1 的写法),tp6是不够灵活的,所以如果要用这种形式必须把之前的where查询也全部改成 2 这种写法:
$where[] = ["day_time","=",$data["day_time"]];

在这里插入图片描述

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}