您当前的位置:首页 > 网站建设笔记 >

discuzX3.3 table_forum_thread类的部分代码注释

0
<?php
class table_forum_thread extends discuz_table {
    private $_posttableid = array();
    private $_urlparam = array();

    public function __construct() {
        $this->_table = 'forum_thread';
        $this->_pk = 'tid';
        $this->_pre_cache_key = 'forum_thread_';
        parent::__construct();
    }
    public function fetch_all_heats() {
        //根据后台设置(界面-界面设置-论坛首页-论坛热点)显示N天内的主题,N乘以一天的总秒数等于N天的总秒数,再使用当前的时间戳减去N天的总秒数
        $heatdateline = getglobal('timestamp') - 86400 * getglobal('setting/indexhot/days');
        $addtablesql = $addsql = '';
        if (!helper_access::check_module('group')) {//自动包含/source/class/helper/helper_access.php
            $addtablesql = " LEFT JOIN ".DB::table('forum_forum')." f ON f.fid = t.fid ";
            $addsql = " AND f.status IN ('0', '1') ";//包括显示或隐藏的版块
        }
        //t.tid 主题id
        //t.posttableid 帖子表ID
        //t.views 浏览次数
        //t.dateline 发表时间
        //t.replies 回复次数
        //t.author 会员名
        //t.authorid 会员id
        //t.subject 标题
        //t.price 价格

        //t.heats 主题热度值
        //t.displayorder 显示顺序
        return DB::fetch_all("SELECT t.tid,t.posttableid,t.views,t.dateline,t.replies,t.author,t.authorid,t.subject,t.price
                FROM ".DB::table('forum_thread')." t $addtablesql
                WHERE t.dateline>'$heatdateline' AND t.heats>'0' AND t.displayorder>='0' $addsql ORDER BY t.heats DESC LIMIT ".(getglobal('setting/indexhot/limit') * 2));//为什么这里会把后台设置论坛热点的条目数乘以2?
        /*
        返回以下格式的数组数据
        Array(
            [0] => Array(
                [tid] => 8
                [posttableid] => 0
                [views] => 17
                [dateline] => 1491010528
                [replies] => 3
                [author] => admin
                [authorid] => 1
                [subject] => discuz 创建模型对象的方法
                [price] => 0
            )
        )
        */
    }
}
?>

建站咨询

在线咨询真诚为您提供专业解答服务

咨询热线

137 1731 25507×24小时服务热线

微信交流

二维码终于等到你,还好我没放弃
返回顶部