Where checkbox, limit and random play together

3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 23, 2015   (RSS)

Greetings once again,

Quick question - as I've enjoyed way too many holiday cookies and drinks, my brain can't seem to see the obvious answer.

Table of Executives, only ones with the "index" checkbox checked show up on a page, limited to one record in random order.

  list($executiveRecords, $executiveMetaData) = getRecords(array(
    'tableName'   => 'executive',
    'where' => "index = '1'",
    'limit'       => '1',
    'orderBy'     => 'RAND()',
    'loadUploads' => true,
    'allowSearch' => true,
  ));

Thanks for your help as always....

By Damon - December 22, 2015

Hi,

Try this code:

  list($executiveRecords, $executiveMetaData) = getRecords(array(
    'tableName'   => 'executive',
    'where' => "`index` = '1'",
    'limit'       => '1',
    'orderBy'     => 'RAND()',
    'loadUploads' => true,
    'allowSearch' => true,
  ));

Let me know if this works for you.

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/