viewer-functions question. Lookup based on two separate conditions.
2 posts by 2 authors in: Forums > CMS Builder
Last Post: August 7, 2008 (RSS)
By MisterJim - August 7, 2008
In viewer_functions.php there is an array parameter written as:
'orWhere' => '', // optional, adding " OR ... " to end of where clause
My question is what does one do if they want to do an AND query using 'where' ? Would it be possible to have a 'andWhere' -- or something similar? If not, is there a way to do an array lookup where you want to base the lookup on two conditions being true?
Jim
'orWhere' => '', // optional, adding " OR ... " to end of where clause
My question is what does one do if they want to do an AND query using 'where' ? Would it be possible to have a 'andWhere' -- or something similar? If not, is there a way to do an array lookup where you want to base the lookup on two conditions being true?
Jim
WebCamp One, LLC
Websites That Work
Websites That Work
Re: [jpietrangelo] viewer-functions question. Lookup based on two separate conditions.
By Dave - August 7, 2008
Hi Jim,
The simplest way to do AND queries is to use search conditions in the url like this:
viewer.php?color=red&year_min=2000
There's docs for that here:
http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html
Next up, more advanced users who are comfortable with MySQL can do a custom where query like this:
'where' => " color = 'red' AND year <= '2000' ",
There's also some special fields that automatically get added to the where if they exist. They are: hidden, publishDate, removeDate, neverRemove. You can read about them here:
http://www.interactivetools.com/docs/cmsbuilder/special_fieldnames.html
So normally if you had a record with a field 'hidden' that was enabled there is no way you could display that record. The 'orWhere' lets you add a condition that is checked in addition to all the default and auto generated SQL. Generally it's only needed for very advanced situations.
Hope that helps. If there is something in particular you are trying to do and you need help with that just let me know.
The simplest way to do AND queries is to use search conditions in the url like this:
viewer.php?color=red&year_min=2000
There's docs for that here:
http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html
Next up, more advanced users who are comfortable with MySQL can do a custom where query like this:
'where' => " color = 'red' AND year <= '2000' ",
There's also some special fields that automatically get added to the where if they exist. They are: hidden, publishDate, removeDate, neverRemove. You can read about them here:
http://www.interactivetools.com/docs/cmsbuilder/special_fieldnames.html
So normally if you had a record with a field 'hidden' that was enabled there is no way you could display that record. The 'orWhere' lets you add a condition that is checked in addition to all the default and auto generated SQL. Generally it's only needed for very advanced situations.
Hope that helps. If there is something in particular you are trying to do and you need help with that just let me know.
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com