public function mergeUsersWithRole(Site $site, $userIdList, $role)
    {
        if (!is_array($userIdList) && !$userIdList instanceof \Traversable) {
            $userIdList = [$userIdList];
        }

        foreach ($userIdList as $userId) {
            // Could be better with a load before and a single bulk insert
            // and a single bulk update, but right now let's go with simple,
            $this
                ->db
                ->merge('ucms_site_access')
                ->key(['site_id' => $site->id, 'uid' => $userId])
                ->fields(['role' => $role])
                ->execute()
            ;
            // Let any exception pass, any exception would mean garbage has
            // been given to this method
        }

        $this->resetCache();
    }
public function mergeUsersWithRole(Site $site, $userIdList, $role)
    {
        if (!is_array($userIdList) && !$userIdList instanceof \Traversable) {
            $userIdList = [$userIdList];
        }

        foreach ($userIdList as $userId) {
            // Could be better with a load before and a single bulk insert
            // and a single bulk update, but right now let's go with simple,
            $this
                ->db
                ->merge('ucms_site_access')
                ->key(['site_id' => $site->id, 'uid' => $userId])
                ->fields(['role' => $role])
                ->execute()
            ;
            // Let any exception pass, any exception would mean garbage has
            // been given to this method
        }

        $this->resetCache();
    }
public function mergeUsersWithRole ( Site $ site , $ userIdList , $ role ) { if ( ! is_array ( $ userIdList ) && ! $ userIdList instanceof \ Traversable ) { $ userIdList = [ $ userIdList ] ; } foreach ( $ userIdList as $ userId ) { // Could be better with a load before and a single bulk insert // and a single bulk update, but right now let's go with simple, $ this -> db -> merge ( 'ucms_site_access' ) -> key ( [ 'site_id' => $ site -> id , 'uid' => $ userId ] ) -> fields ( [ 'role' => $ role ] ) -> execute ( ) ; // Let any exception pass, any exception would mean garbage has // been given to this method } $ this -> resetCache ( ) ; }
Merge users with role

@param Site $site
@param int|int[] $userIdList
@param int $role
Access::ROLE_* constant
Merge users with role