diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-03-10 15:10:08 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2022-03-11 16:09:30 +0000 |
commit | 04ad3ba86396611c1fe53a66a41e72ed38dcda9a (patch) | |
tree | 8e18b1dce3c649c7672e57f12dc46f3afa1d037f | |
parent | 2528a46dc284a22381efb051367eecbcf5bb56b7 (diff) | |
download | nextcloud-server-04ad3ba86396611c1fe53a66a41e72ed38dcda9a.tar.gz nextcloud-server-04ad3ba86396611c1fe53a66a41e72ed38dcda9a.zip |
Don't recreate sql query each time
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
-rw-r--r-- | apps/dav/lib/CardDAV/CardDavBackend.php | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 98e85096b3b..1c1754ff752 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -139,7 +139,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->from('addressbooks') ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); - $result = $query->execute(); + $result = $query->executeQuery(); $column = (int) $result->fetchOne(); $result->closeCursor(); return $column; @@ -1131,18 +1131,18 @@ class CardDavBackend implements BackendInterface, SyncSupport { }, $matches); $cards = []; - foreach (array_chunk($matches, 1000) as $matche) { - $query = $this->db->getQueryBuilder(); - $query->select('c.addressbookid', 'c.carddata', 'c.uri') - ->from($this->dbCardsTable, 'c') - ->where($query->expr()->in('c.id', $query->createNamedParameter($matche, IQueryBuilder::PARAM_INT_ARRAY))); + $query = $this->db->getQueryBuilder(); + $query->select('c.addressbookid', 'c.carddata', 'c.uri') + ->from($this->dbCardsTable, 'c') + ->where($query->expr()->in('c.id', $query->createParameter('matches'))); - $result = $query->execute(); + foreach (array_chunk($matches, 1000) as $matchesChunk) { + $query->setParameter('matches', $matchesChunk, IQueryBuilder::PARAM_INT_ARRAY); + $result = $query->executeQuery(); $cards = array_merge($cards, $result->fetchAll()); $result->closeCursor(); } - return array_map(function ($array) { $array['addressbookid'] = (int) $array['addressbookid']; $modified = false; |