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()]);