saintsystems / odata-client-php

OData Client Library for PHP
MIT License
141 stars 103 forks source link

Where in list #70

Closed solokhind closed 1 month ago

solokhind commented 3 years ago

As of OData 4.01, the in statement is supported.

Here is the example from their documentation:

Example 56: all products whose name value is ‘Milk’ or ‘Cheese’:

http://host/service/Products?$filter=Name in ('Milk', 'Cheese')

http://docs.oasis-open.org/odata/odata/v4.01/csprd02/part2-url-conventions/odata-v4.01-csprd02-part2-url-conventions.html#_Toc486261685

Is there a functionality for this in this library? Thank you

anderly commented 3 years ago

Have you tried $client->where("Field", "contains", "foo")?

solokhind commented 3 years ago

This is a little different, I'm not trying to see if "field" contains "foo". I'm trying to see if "field" value exists in list. In the OData example, you're checking to see if Name equals "Milk" or "Cheese".

I know I can use the orWhere method for this, but it is inefficient.

anderly commented 3 years ago

@ds620107,

I see. I'm going to see if we can get this implemented using a whereIn() method similar to Laravel query builder whereIn method.

Signature would be like $client->whereIn('Name', ['Milk','Cheese'])

Let me know if that would achieve what you're looking for.

solokhind commented 3 years ago

Yes, that would work. Thanks!

joey-carlisle4 commented 2 years ago

any update?

shaedrich commented 2 years ago

I'd need that, too. So, I'm looking forward to it being implemented

n8rowley commented 1 year ago

I'd like to add my voice to those hoping this is still coming

anderly commented 1 month ago

Closed by #117

anderly commented 1 month ago

See tests here for example usage.