public function getUnionFeed($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 ";
// 加上自己的信息,若不需要屏蔽下语句
// $_where = !empty($where) ? "(a.uid = '{$buid}' OR b.uid = '{$buid}') AND ($where)" : "(a.uid = '{$buid}' OR b.uid = '{$buid}')";
$_where = $where . " AND a.uid !={$buid} and (a.uid in (SELECT fid from ts_user_union WHERE uid={$buid}) \n\t\tor a.uid in (SELECT u.fid from ts_user_union u LEFT JOIN ts_user_follow f ON u.uid=f.fid WHERE f.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);
}
//dump($this->getLastSql());
$feed_ids = getSubByKey($feedlist['data'], 'feed_id');
$feedlist['data'] = $this->getFeeds($feed_ids);
return $feedlist;
}