This content has been marked as final. Show 7 replies
use the query-a-query (CFSQL) feature to give new aliases.
In my exp. the performance cost are close to zero.
What's the point in changing the names anyway?
Might want to consider that question first.
Your option 2 would be greatly sped up by the following, but option 1 still wins IMHO:
<cfset qDump = QueryNew("dummyColumn")>
<cfloop index="iColumn" list="#qGetUserData.ColumnList#">
<cfset QueryAddColumn( qDump, iColumn, qGetUserData[iColumn] )>
Of course you have an extra, empty column "dummyColumn" in the end ....
If there is a close to zero overhead to the simple query-a-query then that seems like the way to go, with no need to look for a means of manipulating or modifying the original query.
The reason I want to change the field names is so that the rest of my code can contain references to "CustList.Name" whereas otherwise I would have to do something like "Evaluate('CustList.#NameField#')" which is horribly messy. And the way the original query is generated means I can't use "AS" in it, but I still want to use the same code to work with that query result and other query results that share similar/related data with different field names.
There are more efficient ways to do this, Evaluate() should be hardly ever used.
Please note the use of the variable CurrentRow in the following example. It's the internal counter in cfloop/cfoutput-over-queries.
Same as in <cfloop index="CurrentRow" from="1" to="#myQuery.RecordCount#">
Thanks Stefan! Ignore the "guys" bit below, I didn't originally notice the first two responses both came from you!