Sabre\CardDAV\Backend\PDO::getCards PHP Method

getCards() public method

This method should return the following properties for each card: * carddata - raw vcard data * uri - Some unique url * lastmodified - A unix timestamp It's recommended to also return the following properties: * etag - A unique etag. This must change every time the card changes. * size - The size of the card in bytes. If these last two properties are provided, less time will be spent calculating them. If they are specified, you can also ommit carddata. This may speed up certain requests, especially with large cards.
public getCards ( mixed $addressbookId ) : array
$addressbookId mixed
return array
    function getCards($addressbookId)
    {
        $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, size FROM ' . $this->cardsTableName . ' WHERE addressbookid = ?');
        $stmt->execute([$addressbookId]);
        $result = [];
        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            $row['etag'] = '"' . $row['etag'] . '"';
            $result[] = $row;
        }
        return $result;
    }

Usage Example

Example #1
0
 function testGetCards()
 {
     $result = $this->backend->getCards(1);
     $expected = [['id' => 1, 'uri' => 'card1', 'lastmodified' => 0, 'etag' => '"' . md5('card1') . '"', 'size' => 5]];
     $this->assertEquals($expected, $result);
 }
All Usage Examples Of Sabre\CardDAV\Backend\PDO::getCards