thinkphp排序时,按下级类别数量多的排在前面的写法

 

            $exp =new \think\db\Expression('(SELECT count(*) from `news` where `news`.`comid` = `company`.`comid`) DESC');
            $entlist = Db::name('company')
                ->join('news','company.comid=news.comid')->order($exp)
                ->group('news.comid')
                ->paginate(12,false,['query'=>request()->param()]);

 

posted @ 2021-11-16 09:39  赵瑛  阅读(218)  评论(0编辑  收藏  举报

版权所有 © 2022 沅来是澧

如果有程序开发、网站建设等需求的请联系我,QQ:47419233