FeedModel::recommend_count PHP Method

recommend_count() public method

public recommend_count ( $type, $mid, $since_id, $max_id, $limit = 20, $page = 1, $returnId = false )
    public function recommend_count($type, $mid, $since_id = 0, $max_id = 0, $limit = 20, $page = 1, $returnId = false)
    {
        $since_id = intval($since_id);
        $max_id = intval($max_id);
        $limit = intval($limit);
        $page = intval($page);
        $where = ' a.is_del = 0 ';
        // 动态类型
        if (in_array($type, array('post', 'repost', 'postimage', 'postfile', 'postvideo'))) {
            $where .= " AND a.type='{$type}' ";
        }
        if (!empty($since_id) || !empty($max_id)) {
            !empty($since_id) && ($where .= " AND a.feed_id > {$since_id}");
            !empty($max_id) && ($where .= " AND a.feed_id < {$max_id}");
        }
        $where .= ' AND is_recommend = 1 AND is_audit = 1';
        $start = ($page - 1) * $limit;
        $end = $limit;
        $table = "{$this->tablePrefix}feed AS a LEFT JOIN {$this->tablePrefix}user_follow AS b ON a.uid=b.fid AND b.uid = {$mid}";
        // 加上自己的信息,若不需要此数据,请屏蔽下面语句
        $where = "(a.uid = '{$mid}' OR b.uid = '{$mid}') AND ({$where})";
        $feed_ids = $this->where($where)->table($table)->field('a.feed_id')->limit("{$start},{$end}")->order('a.feed_id DESC')->getAsFieldArray('feed_id');
        return count($feed_ids);
    }