Where Statement Issue

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 2, 2011   (RSS)

By MickC - October 1, 2011

Hi guys,

I am trying to limit my page results to the following criteria:

'Approved'= 1 (checked)
'sales_status' = "in Stock" or "Coming In"

here is my current page query:

list($listingsRecords, $listingsMetaData) = getRecords(array(
'tableName' => 'listings',
'perPage' => '6',
'where' => 'sales_status="In Stock" OR sales_status="Coming In"' and 'approved="1"',


I cant get it to limit it so that all criteria are checked.

I can get it to show the right "sales_status" records, but it ignores the "approved" check.

If I reverse the order of the statement, it show approved records only, but only "in stock" records.

i.e, the AND part is working, and the OR part is working, but not both at the same time.

Im sure its just the way I have the statement worded, but can only find references to WHERE / AND statements, not WHERE / AND /OR statement

Re: [MickC] Where Statement Issue

By Dave - October 2, 2011

Hi MickC,

Try this:
'where' => ' (sales_status="In Stock" OR sales_status="Coming In") and approved="1" ',

I removed some extra single quotes and added brackets to make the logic more explicit.

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com