Combining getRecords Calls?

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

Hello, All

Is it possible to combine multiple, similar getRecords calls?

I've been creating a lot of margin widgets to show links to different articles on a site. One might show a list of links to 5 records in the same section as the current record. Another might show the latest 5 records in all sections, etc, etc...

The getRecords calls used to generate these lists is almost identical. The only thing that changes is the where clause:

list($relatedRecords) = getRecords(array(
  'tableName'   => 'records',
  'where'  => " parenNum = $record['parentNum'] ",
  'limit'  => '5'
));

list($newsRecords) = getRecords(array(
  'tableName'   => 'records',
  'where'  => " category = 7 ",
  'limit'  => '5'
));

list($latestRecords) = getRecords(array(
  'tableName'   => 'records',
  'where' => 'date >= DATE(NOW())',
  'limit'  => '5'
));


Cycling through all of the records on the site 3 times seems to be a waste of overhead. Is there a way to combine the getRecords calls - or do something similar?

:0s

Perch