FollowModel::bulkDoFollow PHP Method

bulkDoFollow() public method

public bulkDoFollow ( $uid, $fids )
    public function bulkDoFollow($uid, $fids)
    {
        $follow_states = $this->getFollowStateByFids($uid, $fids);
        $data = array();
        $_fids = array();
        foreach ($follow_states as $f_s_k => $f_s_v) {
            // 未关注
            if (0 == $f_s_v['following']) {
                // 关注的字段数据
                $data[] = "({$uid}, {$f_s_k}," . time() . ')';
                $_fids[] = $f_s_k;
                $follow_states[$f_s_k]['following'] = 1;
                // 通知和分享
                /*
                 * model('Notify')->send($fid, 'user_follow', '', $uid);
                 * model('Feed')->put('user_follow', array('fid'=>$fid), $uid);
                 */
            } else {
                unset($follow_states[$f_s_k]);
            }
        }
        if (!empty($data)) {
            $sql = "INSERT INTO {$this->tablePrefix}{$this->tableName}(`uid`,`fid`,`ctime`) VALUES" . implode(',', $data);
            $res = $this->execute($sql);
            if ($res) {
                // 关注成功
                $this->error = L('PUBLIC_ADD_FOLLOW_SUCCESS');
                // 更新统计
                $this->_updateFollowCount($uid, $_fids, true);
                return $follow_states;
            } else {
                $this->error = L('PUBLIC_ADD_FOLLOW_FAIL');
                return false;
            }
        } else {
            // 全部已关注
            $this->error = L('PUBLIC_FOLLOW_ING');
            return false;
        }
    }