Where clause on a joined field?

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

By Shore - October 26, 2009

Hello,

I have a video gallery, and each video has a category field. The categories are stored in a separate table called "categories" so I am able to add more categories down the road.

I'm trying to do this:

<?php

require_once "/home/test/public_html/cmsAdmin/lib/viewer_functions.php";

list($videoRecords, $videoMetaData) = getRecords(array(
'tableName' => 'video',
'where' => 'category = "A category"',
));

?>

but it's not understanding my Where clause.

I noticed in CMSB's generated viewer foreach code that the category field was being joined, as below:

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


How do I modify the Where clause from above so that I can create a list of videos from a specific category?

And can I create additional $videoRecords lists for each other category, that way I can arrange each list on the page where I want it.

Thanks

Re: [Shore] Where clause on a joined field?

By Shore - October 26, 2009

After digging through the forum, I figured out why I couldn't do a simple...

'where' => 'category = "category name"'

because for my list field in the video table, I should be using the 'num' field as the option value from the categories table, instead of the title field (which should just be used as the label).

so after I fixed the list field, I'm able to do this...

'where' => 'category = 2',

sorry about that!