Jump to content

Search for one field or another but with different values


mikelexp
 Share

Recommended Posts

Hi!

I've read the selectors documentation but I can't find how to deal with a situation where you need to do something like this, but with PW pages:

SELECT * FROM products WHERE product_name = 'Computer' OR product_category = 'Electronics'

There are 2 OR operators documented, "matching one field or another" ("field1|field2=value") and "matching more than one value in the same field" ("field=value1|value2"), but none of them can do what I need.

I tried something like this: "field1=value1|field2=value2", but of course it didn't work.

I know I could filter the resulting array, but I would be pulling unwanted data from the db and it would break the pagination system.

Link to comment
Share on other sites

Soma beat me to it (couldn't find the info in time :().

Your code might look something like this:

$products = $pages->find("template=product, (product_name=computer, product_category=electronics)");
Link to comment
Share on other sites

Soma beat me to it (couldn't find the info in time :().

Your code might look something like this:

$products = $pages->find("template=product, (product_name=computer, product_category=electronics)");

I think it would be rather

$products = $pages->find("template=product, (product_name=computer), (product_category=electronics)");
  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...