public function setGroupMemberSet($principal, array $members)
    {
        // Grabbing the list of principal id's.
        $stmt = $this->pdo->prepare('SELECT id, uri FROM '.$this->tableName.' WHERE uri IN (? '.str_repeat(', ? ', count($members)).');');
        $stmt->execute(array_merge([$principal], $members));

        $memberIds = [];
        $principalId = null;

        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            if ($row['uri'] == $principal) {
                $principalId = $row['id'];
            } else {
                $memberIds[] = $row['id'];
            }
        }
        if (!$principalId) {
            throw new DAV\Exception('Principal not found');
        }
        // Wiping out old members
        $stmt = $this->pdo->prepare('DELETE FROM '.$this->groupMembersTableName.' WHERE principal_id = ?;');
        $stmt->execute([$principalId]);

        foreach ($memberIds as $memberId) {
            $stmt = $this->pdo->prepare('INSERT INTO '.$this->groupMembersTableName.' (principal_id, member_id) VALUES (?, ?);');
            $stmt->execute([$principalId, $memberId]);
        }
    }
public function setGroupMemberSet($principal, array $members)
    {
        // Grabbing the list of principal id's.
        $stmt = $this->pdo->prepare('SELECT id, uri FROM '.$this->tableName.' WHERE uri IN (? '.str_repeat(', ? ', count($members)).');');
        $stmt->execute(array_merge([$principal], $members));

        $memberIds = [];
        $principalId = null;

        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            if ($row['uri'] == $principal) {
                $principalId = $row['id'];
            } else {
                $memberIds[] = $row['id'];
            }
        }
        if (!$principalId) {
            throw new DAV\Exception('Principal not found');
        }
        // Wiping out old members
        $stmt = $this->pdo->prepare('DELETE FROM '.$this->groupMembersTableName.' WHERE principal_id = ?;');
        $stmt->execute([$principalId]);

        foreach ($memberIds as $memberId) {
            $stmt = $this->pdo->prepare('INSERT INTO '.$this->groupMembersTableName.' (principal_id, member_id) VALUES (?, ?);');
            $stmt->execute([$principalId, $memberId]);
        }
    }
public function setGroupMemberSet ( $ principal , array $ members ) { // Grabbing the list of principal id's. $ stmt = $ this -> pdo -> prepare ( 'SELECT id, uri FROM ' . $ this -> tableName . ' WHERE uri IN (? ' . str_repeat ( ', ? ' , count ( $ members ) ) . ');' ) ; $ stmt -> execute ( array_merge ( [ $ principal ] , $ members ) ) ; $ memberIds = [ ] ; $ principalId = null ; while ( $ row = $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ) { if ( $ row [ 'uri' ] == $ principal ) { $ principalId = $ row [ 'id' ] ; } else { $ memberIds [ ] = $ row [ 'id' ] ; } } if ( ! $ principalId ) { throw new DAV \ Exception ( 'Principal not found' ) ; } // Wiping out old members $ stmt = $ this -> pdo -> prepare ( 'DELETE FROM ' . $ this -> groupMembersTableName . ' WHERE principal_id = ?;' ) ; $ stmt -> execute ( [ $ principalId ] ) ; foreach ( $ memberIds as $ memberId ) { $ stmt = $ this -> pdo -> prepare ( 'INSERT INTO ' . $ this -> groupMembersTableName . ' (principal_id, member_id) VALUES (?, ?);' ) ; $ stmt -> execute ( [ $ principalId , $ memberId ] ) ; } }
Updates the list of group members for a group principal.

The principals should be passed as a list of uri's.

@param string $principal
@param array  $members
Updates the list of group members for a group principal .