House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home / Groups / ColdFusion Talk (CF-Talk)

Best Practice: Looping over a query in cfscript?

Author:
Andy Matthews
11/20/2008 09:43 AM

So yesterday I was working in cfscript and needed to loop over a query. I reviewed my options and decided for elegance sake that a for / in loop was choice. Only problem is that for / in loops in cfscript can't be used with query objects. After trying a few things, I fell back and punted with the following code: qGetTheme = siteGW.GetSiteThemeValuesByThemeID(ARGUMENTS.themeID); colList = qGetTheme.columnlist; for ( item=1;item <= ListLen(colList);item++ ) {             SiteInfo.theme[ListGetAt(colList,item)] = qGetTheme[ListGetAt(colList,item)][1]; } I know this works, and is perfectly legit, but I'd love to see if there's a better way of doing this in cfscript. Anyone? Andy


Search cf-talk

March 22, 2010

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31