> So if I need to loop over the contents of one column of a large
> query, which would be faster:
>
> <cfloop query="big_query">
> ...do stuff with #column1#...
> </cfloop>
>
> <cfloop list="#ValueList(big_query.column1)#" index="i">
> ....do stuff with #i#...
> </cfloop>
>
> <cfset myarray=ListToArray(ValueList(big_query.column1))>
> <cfloop index="i" from="1" to="#ArrayLen(myarray)#">
> ....do stuff with myarray[#i#]...
> </cfloop>
>
> this needs to be a <cfloop> since I'm using tags in it.
Looping over lists, and list functions are always slower than referring
directly to an array or a query
There is another alternative;
If you're not doing a CFOutput
<cfscript>
for (i=1; i lte big_query.recordCount; i=i+1)
{ do stuff with big_query.Column1[i];
}
</cfscript>
or if you need CFOutput
<cfloop index="i" from=1 to="#big_query.recordCount#">
do stuff with big_query.Column1[i]
</cfloop>
Philip Arnold
Director
Certified ColdFusion Developer
ASP Multimedia Limited
T: +44 (0)20 8680 1133
"Websites for the real world"
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists