odata-client-php icon indicating copy to clipboard operation
odata-client-php copied to clipboard

Where in list

Open solokhind opened this issue 4 years ago • 7 comments

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

solokhind avatar Dec 22 '20 21:12 solokhind

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

anderly avatar Jan 13 '21 15:01 anderly

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.

solokhind avatar Jan 13 '21 20:01 solokhind

@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.

anderly avatar Jul 01 '21 14:07 anderly

Yes, that would work. Thanks!

solokhind avatar Jul 01 '21 14:07 solokhind

any update?

joey-carlisle4 avatar May 02 '22 19:05 joey-carlisle4

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

shaedrich avatar Jul 07 '22 13:07 shaedrich

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

n8rowley avatar Aug 04 '23 14:08 n8rowley