phpSPO icon indicating copy to clipboard operation
phpSPO copied to clipboard

adding a filter to query not returning result

Open robwilde opened this issue 10 years ago • 1 comments

wondering if you have used filters in any queries as when I add a filter, like below, there is no result.

`$query = '$select=ClientJobNumber,ID,ClientJobNumber,ClientPassword,ClientUserName,ClientUserName,ClientsFirstName,ClientsLastName';

$filter = '?$filter=ClientJobNumber eq '56654'';`

If I run only the query everything works fine. I have also tested the query with the filter using REST API tester and everything works great

robwilde avatar Feb 09 '16 14:02 robwilde

Greetings!

Currently the SDK supports the query options listed in OData system query options using the OData endpoint MSDN page.

Examples

Example 2. How to select only a specific set of fields(properties) for list items

$items = $list->getItems()->select('ClientJobNumber,ID,ClientPassword,ClientUserName,ClientUserName,ClientsFirstName,ClientsLastName');  //apply select query option
$ctx->load($items);
$ctx->executeQuery();
foreach( $items->getData() as $item ) {
    print "Task: {$item->ClientJobNumber}\r\n";
}

Example 3. How to find a specific list item(s)

$items = $list->getItems()->filter("ClientJobNumber eq '56654'");  //apply filter query option
$ctx->load($items);
$ctx->executeQuery();
foreach( $items->getData() as $item ) {
    print "Task: '{$item->ClientJobNumber}'\r\n";
}

Please follow listitem_examples.php for a more examples.

vgrem avatar Apr 25 '16 21:04 vgrem