Problem with where clause...

5 posts by 2 authors in: Forums > CMS Builder
Last Post: September 9, 2014   (RSS)

By claire - September 9, 2014

Hi Kitka

The problem you're having here is that you're basically overriding the first 'orWhere' variable. Here's your getRecords function:

// load records from 'equipment_for_sale'
list($equipment_for_saleRecords, $equipment_for_saleMetaData) = getRecords(array(
'tableName' => 'equipment_for_sale',
'where' => "equipment_type = 'municipal equipment'",
'orWhere' => "additional_equipment_type_1 = 'municipal equipment'",
'orWhere' => "additional_equipment_type_2 = 'municipal equipment'",

'loadUploads' => true,
'allowSearch' => false,
));

That second 'orWhere' overrides the first one, so that it's as if you wrote it like this:

// load records from 'equipment_for_sale'
list($equipment_for_saleRecords, $equipment_for_saleMetaData) = getRecords(array(
'tableName' => 'equipment_for_sale',
'where' => "equipment_type = 'municipal equipment'",
'orWhere' => "additional_equipment_type_2 = 'municipal equipment'",

'loadUploads' => true,
'allowSearch' => false,
));

These things are not cumulative, unfortunately. You can only assign the various options for getRecords once - so only one 'where', only one 'orWhere', only one 'tableName', etc. So - you'll need to modify the getRecords query into something like this, combining the two:

// load records from 'equipment_for_sale'
list($equipment_for_saleRecords, $equipment_for_saleMetaData) = getRecords(array(
'tableName' => 'equipment_for_sale',
'where' => "equipment_type = 'municipal equipment'",
'orWhere' => "(additional_equipment_type_1 = 'municipal equipment' OR additional_equipment_type_2 = 'municipal equipment')",

'loadUploads' => true,
'allowSearch' => false,
));

This should get both equipment types showing up. I'm not 100% sure how you want the logic to work here.

Let me know if this works.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By kitka - September 9, 2014 - edited: September 9, 2014

Thanks Claire...
After about 3 hours I  accidentally got the same solution ...........)  it works! 

You  and your staff folks at interactivetools offer great support!  Well appreciated...  If you ever need a testimonial feel free to ask.  JIM.

PS ... My  client is very happy with your software... very easy to use as usual...

jim albert

By claire - September 9, 2014

No bother :P sorry I didn't get to this sooner, I might have saved you some time!

Let us know if you need any more help.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By kitka - September 9, 2014

that's alright...

always good to learn something new each day....

thank you for looking into this for me... Always appreciated....

Have a  great night

JIM

jim albert