TrackRecordPro API Documentation TrackRecordPro

Building Filter Queries

The $filters variable passed to the methods within the TRAPI class allows for searching within the records contained in an endpoint.

Simple Queries

You should structure $filters as an array containing field names and potential values. At it's simplest, it is just an array of fieldname=value pairs, for example to find all users with id=53:

$result = $tr->getUsers(["id"=>53]);

All values must be matched against each record.

Sort Order

You can specify the sort order of your results by chaining the asc() and desc() methods of the API object, for example:

$result = $tr->asc("users.first_name")->asc("users.last_name")->getUsers(["id"=>53]);

The sort order set by asc() and desc() only apply to the next "get" method call, e.g. in the example above after getUsers() is called, all sort ordering is cleared ready for the next method call.

Advanced Queries

For more advanced queries, you can suffix each field name with a matching operation from the table below:

SuffixAction
<Less Than
>Greater Than
=Equal
!Not Equal
~Wildcard match (contains)

For example to find all users with an email address containing "comech.co.uk" and containing "sales" with an ID greater than 1050:

$result = $tr->getUsers(["email~" => "comech.co.uk", "email~" => "sales", "id>" => 1050]);