FollowModel::getFollowCount PHP Méthode

getFollowCount() public méthode

获取指定用户的关注与粉丝数
public getFollowCount ( array $uids ) : array
$uids array 用户ID数组
Résultat array 指定用户的关注与粉丝数
    public function getFollowCount($uids)
    {
        $count = array();
        foreach ($uids as $u_v) {
            $count[$u_v] = array('following' => 0, 'follower' => 0);
        }
        $following_map['uid'] = $follower_map['fid'] = array('IN', $uids);
        // 关注数
        $following = $this->field('COUNT(1) AS `count`,`uid`')->where($following_map)->group('`uid`')->findAll();
        foreach ($following as $v) {
            $count[$v['uid']]['following'] = $v['count'];
        }
        // 粉丝数
        $follower = $this->field('COUNT(1) AS `count`,`fid`')->where($follower_map)->group('`fid`')->findAll();
        foreach ($follower as $v) {
            $count[$v['fid']]['follower'] = $v['count'];
        }
        return $count;
    }