We support three types of search fields:

  • Text fields
  • Multiple value fields
  • Range fields

Learn more about working with search results.

Text fields

Text Fields can be searched using 5 operators: is, isNot, startsWith, endsWith, and contains. Each search Text Field can't exceed 255 characters. Here is an example searching for customer email on a transaction.

PHP
Copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::customerEmail()->is('tom smith')
]);

$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::customerEmail()->isNot('somebody else')
]);

$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::customerEmail()->startsWith('tom s')
]);

$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::customerEmail()->endsWith('m smith')
]);

$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::customerEmail()->contains('m sm')
]);

Multiple value fields

Search fields that accept multiple values support two operators: is and in.

PHP
Copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::status()->is(
    Braintree_Transaction::GATEWAY_REJECTED
  )
]);
$collection = Braintree_Transaction::search([
    Braintree_TransactionSearch::id()->is($transaction->id),
    Braintree_TransactionSearch::status()->in(
      [
        Braintree_Transaction::GATEWAY_REJECTED,
        Braintree_Transaction::SETTLED
      ]
    )
]);

Range fields

Ranges support four operators: is, between, greaterThanOrEqualTo, and lessThanOrEqualTo. between is inclusive.

PHP
Copy
Copied
$collection = Braintree_Transaction::search([
    Braintree_TransactionSearch::amount()->is('1500')
]);

$collection = Braintree_Transaction::search([
    Braintree_TransactionSearch::amount()->greaterThanOrEqualTo('1700')
]);

$collection = Braintree_Transaction::search([
    Braintree_TransactionSearch::amount()->lessThanOrEqualTo('1250')
]);

$collection = Braintree_Transaction::search([
    Braintree_TransactionSearch::amount()->between('1100', '1600')
]);

$collection = Braintree_Transaction::search([
    Braintree_TransactionSearch::createdAt()->between("12/17/2015 17:00", "12/17/2015 17:00")
]);
note

Date ranges are precise to the minute, so the results of search for transactions created between 12/17/2015 17:00 and 12/17/2015 17:00 will include a transaction created at 12/17/2015 17:00:59.

Still have questions?

If you can’t find an answer, contact our Support team.