FeedModel::friends_counts PHP Method

friends_counts() public method

获取我关注的和我的分享总数
public friends_counts ( $type = 'original', $mid )
    public function friends_counts($type = 'original', $mid = 0)
    {
        $mid = $mid ? $mid : $GLOBALS['ts']['mid'];
        $where = ' a.is_del = 0 ';
        //排除类型
        if ($type == 'original') {
            $where .= " AND a.type<>'repost' && a.type <>'weiba_post' ";
        } else {
            //动态类型
            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}";
        //            }
        //            $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')->order('a.feed_id DESC')->getAsFieldArray('feed_id');
        $feed_ids = is_array($feed_ids) ? $feed_ids : array();
        return count($feed_ids);
    }