Limt in query not working

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

By InHouse - October 18, 2011

I'm trying to use a List View to show a single record. The records may have a "coming soon" checkbox value and a "featured" checkbox. I want to show the first record that is checked as coming soon, but failing that, show the first record which is featured. I'm using the following query:

list($collectionsRecords, $collectionsMetaData) = getRecords(array(
'tableName' => 'collections',
'limit' => '1',
'orderBy' => 'coming_soon DESC, featured DESC, collection',
'allowSearch' => '0',
));


But, for some reason the limt => '1' is not being honoured so I'm seeing the entire list of records. Plus, it's being ordered by 'collection' and not the first options.

Can anyone shed some light on this for me?

Re: [Jason] Limt in query not working

By InHouse - October 18, 2011 - edited: October 19, 2011

Thanks Jason.

I've added a where clause to control the results based on another variable in the data.

My thinking with this was that in the likely event that nothing was "coming soon", then the query would fall back to the first "featured". If none of those are present, then just grab the first record in the colleciton. But this relies on the limit of 1 actually working.

I'll take a look at the rest of the page to see if something in hijacking the response. You just have to love inheriting projects from other people - you never know what else is being done.


FOLLOW UP:
Turns out there was another query in an include file which was hijacking the process. Changed the names of the queried list variables and all was well again. Thanks for pointing me in the right direction Jason. BTW, the use of OrderBy in this way worked well as a type of "if" statement.