Hm, I'd think I'd do that loop the same way with cfloop - there is no
cfloop shortcut for looping over the query columns. What you have
there is fine though I would personally use an array instead of a list
in the loop as it is generally more efficient and easier to read in my
opinion:
qGetTheme = siteGW.GetSiteThemeValuesByThemeID(ARGUMENTS.themeID);
cols = ListToArray( qGetTheme.columnlist );
nCols = ArrayLen(cols);
for ( item=1;item <= nCols; item++ ) {
SiteInfo.theme[ cols[item] ] = qGetTheme[ cols[item] ][1];
}
Looping over the rows of the query would be slightly different
however. Here is a neat but undocumented way to loop a query in
cfscript:
<cfscript>
foo = QueryNew('');
bar = [1,2,3,4];
QueryAddColumn(foo,'bar','integer',bar);
while(foo.next()){
writeoutput(foo.bar[foo.getCurrentRow()]);
}
</cfscript>
Output would be: 1234
HTH
Dominic
2008/11/20 Andy Matthews <[EMAIL PROTECTED]>:
> 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
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:315681
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4