默认情况下,群组积分排行是所有时间内的积分排行,但是有时候站长更需要最近时间的排行,比如说30天内排行,90天内排行。
直接上代码吧。
$topgrouplist = array();
$olddate = date('Ymd', TIMESTAMP - 90*86400); // 获取90天内排名
$rs = DB::fetch_all('select count(1) as credit, fid from %t forum_groupcreditslog where logdate >= %s group by fid order by credit desc limit 12', array('forum_groupcreditslog', $olddate));
foreach($rs as $v) {
$_group = DB::fetch_first("SELECT * FROM ".DB::table('forum_forum')." f LEFT JOIN ".DB::table("forum_forumfield")." ff ON ff.fid=f.fid WHERE f.fid = {$v['fid']} and f.type='sub' AND f.status=3");
$_group['commoncredits'] = $v['credit'];
isset($_group['icon']) && $_group['icon'] = get_groupimg($_group['icon'], 'icon');
$topgrouplist[] = $_group;
}
上面代码是获取90天内的积分排名,dz默认是通过forum_forum表里的commoncredits计算排名,我是通过forum_groupcreditlog表来计算排名,一个新帖会往这个表里插入一条数据。
有关PHP系统、Discuz或网站等各种问题,可以联系QQ1069971363寻求付费支持
|