Chunk the array of phone numbers
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
6e2f7ddc7a
commit
6951c4ef56
|
@ -229,19 +229,23 @@ class AccountManager implements IAccountManager {
|
|||
}
|
||||
|
||||
public function searchUsers(string $property, array $values): array {
|
||||
$chunks = array_chunk($values, 500);
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from($this->dataTable)
|
||||
->where($query->expr()->eq('name', $query->createNamedParameter($property)))
|
||||
->andWhere($query->expr()->in('value', $query->createNamedParameter($values, IQueryBuilder::PARAM_STR_ARRAY)));
|
||||
->andWhere($query->expr()->in('value', $query->createParameter('values')));
|
||||
|
||||
$result = $query->execute();
|
||||
$matches = [];
|
||||
foreach ($chunks as $chunk) {
|
||||
$query->setParameter('values', $chunk, IQueryBuilder::PARAM_STR_ARRAY);
|
||||
$result = $query->execute();
|
||||
|
||||
while ($row = $result->fetch()) {
|
||||
$matches[$row['value']] = $row['uid'];
|
||||
}
|
||||
$result->closeCursor();
|
||||
}
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue