Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Filter by "where" not working

 

 


gversion
User

Nov 28, 2011, 3:47 PM

Post #1 of 3 (190 views)
Shortcut
Filter by "where" not working Can't Post

Hello,

I am trying to load my listing records using the following code:


Code
 
list($listingRecords, $listingDetails) = getRecords(array(
'tableName' => 'listings',
'where' => "status <> '1'",
'where' => "listing_type = '1'",
'ignoreHidden' => 'true',

));


I only want to display records with a status of 0 or 3, however the "where" code I am using to define the "status" doesn't make any difference. All records are being displayed no matter what their status.

Is there something I am missing or doing wrong, perhaps because I am trying to use two "where" statements?

Thanks for any help you can offer.

Regards,
Greg


robin
User / Moderator


Nov 29, 2011, 9:33 AM

Post #2 of 3 (182 views)
Shortcut
Re: [gversion] Filter by "where" not working [In reply to] Can't Post

Hey Greg,

Only the last where statement will have effect. You can combine sql conditions with "AND". Something like this should work for you:


Code
 list($listingRecords, $listingDetails) = getRecords(array(  
'tableName' => 'listings',
'where' => "status <> '1' AND listing_type = '1'",
'ignoreHidden' => 'true',

));


Some reference: http://www.w3schools.com/sql/sql_and_or.asp

Hope that helps,
Robin


gversion
User

Nov 29, 2011, 9:41 AM

Post #3 of 3 (180 views)
Shortcut
Re: [robin] Filter by "where" not working [In reply to] Can't Post

Hi Robin,

Thanks for helping me out with that one!

Regards,
Greg