限时免费试用:欢迎注册 api.bigmodel.org ,快速体验大模型 API 接入服务。

ThinkPHP

点赞+问答+文章相加对用户进行排序

$list = Db::query("SELECT u.*, (select count(1) FROM zf_post where uid=u.id and `status`=1) as p_count, (select count(1) FROM zf_like where uid=u.id) as l_count, (select count(1) F

作者
王明昌
发布时间
最后更新
$list = Db::query("SELECT
            u.*,
            (select count(1) FROM zf_post where uid=u.id and `status`=1) as p_count,
            (select count(1) FROM zf_like where uid=u.id) as l_count,
            (select count(1) FROM zf_comment where uid=u.id) as c_count
            FROM
                zf_user u
            GROUP BY p_count+l_count+c_count DESC");

反馈邮箱