where for a list field problem

7 posts by 2 authors in: Forums > CMS Builder
Last Post: July 3, 2017   (RSS)

By dlsweb - July 2, 2017

I'm confused. For a winery in thomas county included in my one table

This works to show the entry (among others)
'tableName' => 'entry',
'loadUploads' => true,
'where' => 'county = "Thomas"',
'allowSearch' => false,

But this does not, 
'tableName' => 'entry',
'loadUploads' => true,
'where' => 'category = "Winery"',
'allowSearch' => false,

the only difference is that category is a list field (checkboxes (multi value)), there are some with multiple entries (comma seperated in database)
nor does any other category entry work

Thanks

By dlsweb - July 3, 2017 - edited: July 3, 2017

the $ did not work
'where' => 'category = "$Winery$"', 
Gets No records were found!

category is in the same table, and my value and label are exactly the same.

Thanks, Larry

By Deborah - July 3, 2017

Larry, so sorry. The $ was a typo. Did you try this with the %?

~ Deborah

By dlsweb - July 3, 2017 - edited: July 3, 2017

tried both with no luck- so it is supposed to be %cat%

By Deborah - July 3, 2017

Yes. The following is what I'm using:

list($items_inRecords, $items_inMetaData) = getRecords(array(
'tableName' => 'apples'
'loadUploads' => true,
'allowSearch' => false,
'where' => ' category LIKE "%Sweet%" ',
));

Then in the HTML:

<?php echo join(', ', $record['category:values']); ?>

Resulting display:
Red Delicious, Fuji, Golden Delicious

By dlsweb - July 3, 2017 - edited: July 3, 2017

I had not tried the % and the LIKE
This works
'where' => 'category LIKE "%mycategory%"',

Thanks so very much for the help, you're terrific

Larry