Don't recreate sql query each time

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
pull/31551/head
Carl Schwan 2022-03-10 15:10:08 +07:00 committed by Christoph Wurst
parent 13366f4820
commit 8e69237b0d
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
1 changed files with 6 additions and 6 deletions

@ -1111,18 +1111,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')));
foreach (array_chunk($matches, 1000) as $matchesChunk) {
$query->setParameter('matches', $matchesChunk, IQueryBuilder::PARAM_INT_ARRAY);
$result = $query->execute();
$cards = array_merge($cards, $result->fetchAll());
$result->closeCursor();
}
return array_map(function ($array) {
$array['addressbookid'] = (int) $array['addressbookid'];
$modified = false;