thinkphp6 判断数据集数组是否为空的方法
2022-11-24 11:10:29
236
{{single.collect_count}}

修改配置数据库database.php的resultset_type参数如下:

// 数据集返回类型'resultset_type' => 'collection',(数据库的查询结果也就是数据集,默认的配置下,数据集的类型是一个二维数组,我们可以配置成数据集类,就可以支持对数据集更多的对象化操作)
如果要判断数据集是否为空,而必须使用数据集对象的isEmpty方法判断:
$users = Db::name('user')->select();if($users->isEmpty()){echo '数据集为空';}
官方说明请访问:https://www.kancloud.cn/manual/thinkphp5/150164
回帖
全部回帖({{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 ? '加载中...' : '查看更多评论'}}