Search queries: AND

8 posts by 3 authors in: Forums > CMS Builder
Last Post: March 7, 2018   (RSS)

By gversion - March 5, 2018

Hello,

Can I have multiple search form fields search the same listing field using an AND operator?

e.g. /search.php?product=Sony&product=HD

-> this will display all listings with "Sony" AND "HD" in the product field.

Will this work or should I be doing this some other way?

Thank you.

Greg

By Dave - March 5, 2018

Hi Greg, 

Yes, that's what it will do by default so that should work no problem.

Let me know if you have any other questions.

Dave Edis - Senior Developer
interactivetools.com

By gversion - March 5, 2018

Hi Dave,

Thanks for getting back to me. That's great!

And if I want to use an OR operator then I would do this:

/search.php?product_keyword[]=Sony&product_keyword[]=HD

Is that right?

Thanks again.

Greg

By Dave - March 6, 2018

Hi Greg, 

Yes, that's right.  And if you want to see the actual MySQL that is being generated for debugging purposes you can add the option: 

'debugSql' => true,

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By gversion - March 6, 2018

Hi Dave,

That's useful to know, thanks.

Also, can you clarify what the difference is (if any) between:

/search.php?product_keyword[]=Sony&product_keyword[]=HD

...and

/search.php?product[]=Sony&product[]=HD

Thank you,

Greg

By Dave - March 7, 2018

Hi Guys, 

Yea, that's right.  *_keyword matches if the keyword is anywhere in the value.  Otherwise, it needs to be an exact match.

Reference: https://www.interactivetools.com/docs/cmsbuilder/viewer_search.html

Dave Edis - Senior Developer
interactivetools.com

By gversion - March 7, 2018

Thanks guys for your help! Really good to now understand this.

Regards,

Greg