Skip to content

Commit 2cdaa28

Browse files
committed
Don't recreate sql query each time
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent cb7485e commit 2cdaa28

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

apps/dav/lib/CardDAV/CardDavBackend.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function getAddressBooksForUserCount($principalUri) {
139139
->from('addressbooks')
140140
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
141141

142-
$result = $query->execute();
142+
$result = $query->executeQuery();
143143
$column = (int) $result->fetchOne();
144144
$result->closeCursor();
145145
return $column;
@@ -1131,18 +1131,18 @@ private function searchByAddressBookIds(array $addressBookIds,
11311131
}, $matches);
11321132

11331133
$cards = [];
1134-
foreach (array_chunk($matches, 1000) as $matche) {
1135-
$query = $this->db->getQueryBuilder();
1136-
$query->select('c.addressbookid', 'c.carddata', 'c.uri')
1137-
->from($this->dbCardsTable, 'c')
1138-
->where($query->expr()->in('c.id', $query->createNamedParameter($matche, IQueryBuilder::PARAM_INT_ARRAY)));
1134+
$query = $this->db->getQueryBuilder();
1135+
$query->select('c.addressbookid', 'c.carddata', 'c.uri')
1136+
->from($this->dbCardsTable, 'c')
1137+
->where($query->expr()->in('c.id', $query->createParameter('matches')));
11391138

1140-
$result = $query->execute();
1139+
foreach (array_chunk($matches, 1000) as $matchesChunk) {
1140+
$query->setParameter('matches', $matchesChunk, IQueryBuilder::PARAM_INT_ARRAY);
1141+
$result = $query->executeQuery();
11411142
$cards = array_merge($cards, $result->fetchAll());
11421143
$result->closeCursor();
11431144
}
11441145

1145-
11461146
return array_map(function ($array) {
11471147
$array['addressbookid'] = (int) $array['addressbookid'];
11481148
$modified = false;

0 commit comments

Comments
 (0)