Fraser
Fraser

Reputation: 14246

Silverstripe: DataList Filter equivalent of 'Value > x OR Value = y'

I understand that I can specify multiple values for my filter in a way such as:

xxx::get()->filter('FirstName', array('Sam', 'Sig'));

Which gives me the equivalent of:

... WHERE FirstName = 'Sam' OR FirstName = 'Sig'

However, there doesn't appear to be anyway of combining OR's with the modifiers ('LastVisited:GreaterThan' => '2011-01-01')

I need to be able to filter like so:

WHERE ExpiryDate > 29-11-2012 OR ExpiryDate IS NULL

Is what I am trying to achieve possible? I have read the docs but have not found the answer to my issue.

Thanks

Upvotes: 4

Views: 3359

Answers (1)

3dgoo
3dgoo

Reputation: 15794

You could always use the where() function if nothing else will do what you need.

xxx::get()->where("\"ExpiryDate\" > 29-11-2012 OR \"ExpiryDate\" IS NULL");

http://doc.silverstripe.org/framework/en/topics/datamodel#where-clauses

Upvotes: 6

Related Questions