Filter by select attribute, by multiple values

Permalink 1 user found helpful
Does anybody knows if it's possible to filter by multiple select values in a logical AND way, so for example all pages that have option1 AND option2 selected for attribute1
Page search in the dashboard does a logical OR.
One obvious solution is to use filterByAttribute() or filterByAttrebute1() for each value and intersect the result sets, but that's very inefficient.
Thanx, Guy

View Replies:
ronyDdeveloper replied on at Permalink Reply
The user "TheRealSean" have already discussed it in this forum. Here is the link:

He also attached a sample work for have a try. So you can try your own way with this attached piece of code.

guyDesign replied on at Permalink Reply
Thanx, Looked through the code, it seems like he is filtering the select options themselves.
What I would like to do is filter pages by multiple select options of an attribute.
guyDesign replied on at Permalink Reply
Got it like so:

$option1 = 'option1';
$option2 = 'option2';
$pl->filterByAttribute('select_attribute_to_filter', "%\n{$option1}\n%{$option2}\n%", "LIKE");

This approach assumes that the options in the query are in the same order as they are set for the attribute, which is enough for me, to get around this limitation you would probably need MySQL regex