Search Fields
We support three types of search fields: text fields, multiple value fields, and range fields.
Text Fields
Text Fields can be searched using 5 operators: is, is not, starts with, ends with, and contains. Here is an example searching for customer email on a transaction.
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::creditCardCardholderName()->is('tom smith')
));
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::creditCardCardholderName()->isNot('somebody else')
));
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::creditCardCardholderName()->startsWith('tom s')
));
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::creditCardCardholderName()->endsWith('m smith')
));
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::creditCardCardholderName()->contains('m sm')
));
Multiple Value Fields
Search fields that accept multiple values support two operators: is and in.
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::status()->is(
Braintree_Transaction::GATEWAY_REJECTED
)
));
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::id()->is($transaction->id),
Braintree_TransactionSearch::status()->in(
array(
Braintree_Transaction::GATEWAY_REJECTED,
Braintree_Transaction::SETTLED
)
)
));
Range Fields
Ranges support four operators: is, between, >=, and <=. Between is inclusive.
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::amount()->is('1500')
));
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::amount()->greaterThanOrEqualTo('1700')
));
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::amount()->lessThanOrEqualTo('1250')
));
$collection = Braintree_Transaction::search(array(
Braintree_TransactionSearch::amount()->between('1100', '1600')
));