FeedModel::getFollowingFeed PHP Method

getFollowingFeed() public method

获取指定用户所关注人的所有分享,默认为当前登录用户
public getFollowingFeed ( string $where = '', integer $limit = 10, integer $uid = '', integer $fgid = '', $max = null ) : array
$where string 查询条件
$limit integer 结果集数目,默认为10
$uid integer 指定用户ID,默认为空
$fgid integer 关组组ID,默认为空
return array 指定用户所关注人的所有分享,默认为当前登录用户
    public function getFollowingFeed($where = '', $limit = 10, $uid = '', $fgid = '', $max = null)
    {
        $fgid = intval($fgid);
        $uid = intval($uid);
        $buid = empty($uid) ? $_SESSION['mid'] : $uid;
        $table = "{$this->tablePrefix}feed AS a LEFT JOIN {$this->tablePrefix}user_follow AS b ON a.uid=b.fid AND b.uid = {$buid}";
        // 加上自己的信息,若不需要屏蔽下语句
        $_where = !empty($where) ? "(a.uid = '{$buid}' OR b.uid = '{$buid}') AND ({$where})" : "(a.uid = '{$buid}' OR b.uid = '{$buid}')";
        // 若填写了关注分组
        if (!empty($fgid)) {
            $table .= " LEFT JOIN {$this->tablePrefix}user_follow_group_link AS c ON a.uid = c.fid AND c.uid ='{$buid}' ";
            $_where .= ' AND c.follow_group_id = ' . intval($fgid);
        }
        $feedlist = $this->table($table)->where($_where)->field('a.feed_id')->order('a.feed_id DESC');
        //2013-10-01 为了提高效率增加一项改进,可以设置查看的分享总数,默认10000条
        if ($max > 0) {
            $feedlist = $this->findPage($limit, $max);
        } else {
            $feedlist = $this->findPage($limit);
        }
        $feed_ids = getSubByKey($feedlist['data'], 'feed_id');
        $feedlist['data'] = $this->getFeeds($feed_ids);
        return $feedlist;
    }