在thinkphp6中,应该如何用in查询
2022-11-24 11:10:29
156
{{single.collect_count}}

当一个非常简单的查询,我们直接这样写就可以了。

$where = [];

$where['status'] = 1;

$lst = $this->where($where)->select();

如何涉及到比较复杂的查询,有in这样的嵌套查询,那么就必须这样写。

 

$where = [];

$where[] = ['memberid','=',$uid];

$where[] = ['itemid','in',$cartIds];

$lst = $this->where($where)->select();

备注:$cartIds 是一个字符串。

 

回帖
全部回帖({{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 ? '加载中...' : '查看更多评论'}}