Search results implement
Iterator so you can use
foreach to iterate over them.
To optimize the processing of large searches, data is retrieved from the server lazily.
Initially, the server returns a list of ids that matched the search criteria. While you're iterating over search results, the data for each record is fetched dynamically. This causes race conditions to exist when records are modified on the server while you are iterating over them.
If a record is deleted server-side while you are iterating over the results, that record is skipped.
If a record is updated server-side while you are iterating over the results, one of two things could happen:
- the record still matches the search criteria and the modified record is returned
- the record no longer matches the search criteria and is skipped
Because of the race conditions described above, you can't know how many search results you have while iterating over them. You do, however, know the maximum number of results that will be given.
$collection = $gateway->transaction()->search([ Braintree_TransactionSearch::amount()->between('1100', '1600') ]); $collection->maximumCount() # e.g. 33
Transaction searches return a maximum of 20,000 results; all other searches return a maximum of 10,000 results.
Still have questions?
If you can’t find an answer, contact our Support team