1. Go to this page and download the library: Download curiosity26/odataquery library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$search = $path->getSearch();
// operations functions are both setters and getters. When setting, the funciton returns the $path object for chainability
$search->_and('balloon');
$path->setSearch($search);
$filter = new ODataGreaterThanEqualsFilter('YearsEmployed', 6); // YearsEmployed ge 6
$path->setFilter($filter);
$add_filter = new ODataAddFilter('YearsEmployed', 5); // YearsEmployed add 5
$filter = $add_filter->greaterThanEquals(6); // YearsEmployed add 5 ge 6
$path->setFilter($filter);
$sub_filter = new ODataSubtractFilter('YearsEmployed', 'YearsSebatical'); // YearsEmployed sub YearsSebatical
$sub_filter2 = new ODataAddFilter('Awards', 'Demotions'); // Awards sub Demotions
$filter = $sub_filter->greaterThan($sub_filter2); // (YearsEmployed sub YearsSebatical) gt (Awards sub Demotions)
$path->setFilter($filter);
$pager = new ODataQueryPager(20, 5); // $top=20&$skip=100
$path->setPager($pager);
$path->setOrderBy('LastName');
$collection = new ODataQueryExpandCollection();
$expand1 = new ODataQueryExpand('FirstName'); // Expand upon the FirstName property
$filter = new ODataEqualsFilter('$it', "'Alex'"); // Only string filter functions safely wrap strings. Other filters can't distinguish between a regular string function or a property name
$expand1->filter($filter);
$collection->add($expand1);
$expand2 = new ODataQueryExpand('LastName'); // Expand upon the LastName property
$search = new ODataQuerySearch("Boyce");
$expand2->search($search); // Search the last name
$collection->add($expand2);
$expand3 = new ODataQueryExpand('Address');
$expand4 = new ODataQueryExpand('City'); // Assuming the Address is an object containing City and not a sibling of City
$search2 = new ODataQuerySearch('New York');
$expand4->search($search2);
$expand3->expand(new ODataQueryExpandCollection(array($expand4))); // Add $expand4 to $expand3, wrapping it in a collection
$collection->add($expand3);
$path->expand($collection);
// OUTPUT PATH: http://www.example.com/test/api/Employees?$expand=FirstName($filter=$it eq 'Alex'),LastName($search=Boyce),Address($expand=City($search="New York"))
$params = new ODataQueryParameterCollection();
$params->myParam1 = 10;
$params->otherParam = "Other";
$filter = new ODataLessThanEquals('@otherPraram', '@myParam1');
$path->filter($filter)->parameters($params);
// OUTPUT PATH: http://www.example.com/test/api/Employees?$filter=@otherParam le @myParam1&@myParam1=10&@otherParam=Other
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.