working with WHERE clause

2 posts by 2 authors in: Forums > CMS Builder
Last Post: May 3, 2011   (RSS)

Re: [kovali] working with WHERE clause

By gkornbluth - May 3, 2011

Hi Koen,

The simplest that I can think of is just to repeat the "get records" call on the viewer and use different where criteria for each.

So...

<?php
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'where' => 'category="Audi"',
'limit' => '1',
?>
Audi News
Latest Audi news article goes here...

<?php
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'where' => 'category="Skoda"',
'limit' => '1',
?>
Skoda News
Latest Skoda news article goes here...

<?php
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'where' => 'category="VW"',
'limit' => '1',
?>
VW News
Latest VW news article goes here...

The wheres can be as simple or as complex as required, and you can use 'orderBy' to change the order in each call if required.

Give it a try...

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php