'Where' clause validation

4 posts by 2 authors in: Forums > CMS Builder
Last Post: August 20, 2008   (RSS)

Re: [terryally] 'Where' clause validation

Problem solved.

Please ignore.

Re: [terryally] 'Where' clause validation

By terryally - August 20, 2008 - edited: August 20, 2008

Apologies to all. Here is the solution.

It seems that CMS Builder is much more efficient that writing a SELECT statement and query.

What I did was to generate the code using the WHERE clause for each category I wanted to display. Remember my categories are "Starter", "Main", "Dessert" etc. The field name of my categories is called "course" so I generated the code for <course="Starter"> and got the following:

list($lunch_menuRecords, $lunch_menuMetaData) = getRecords(array(
'tableName' => 'lunch_menu',
'where' => 'course="Starter"',
));


Which I placed immediately before the loop, viz

<?php
list($lunch_menuRecords, $lunch_menuMetaData) = getRecords(array(
'tableName' => 'lunch_menu',
'where' => 'course="Starter"',
));
?>


<?php foreach ($lunch_menuRecords as $record): ?>

<?php echo $record['item'] ." ". $record['cost'] ?><br/>
<?php echo $record['description'] . " " .$record['notes'] ?><br/>

<?php endforeach; ?>


I then repeat the same for Main Course and Desserts.

So the difference is that I did not place the code at the top of the page before everything else (except the include file: require_once "/my/path/to/cms-admin/lib/viewer_functions.php";) but immediately before the loop.

The results can be viewed at the development site: http://lakesideint.server266.com/dining/menu_lunch.php

Cheers
Terry

Re: [terryally] 'Where' clause validation

By Donna - August 20, 2008

Hey Terry! Glad to hear you got that sorted out -- thanks for sharing! :)
Donna

--
support@interactivetools.com