Created
August 21, 2013 13:17
-
-
Save nastanford/6294328 to your computer and use it in GitHub Desktop.
Query to array of Structures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="querytoarray" returntype="array" output="No"> | |
<cfargument name="q" required="Yes" type="query"> | |
<cfset var aTmp = arraynew(1)> | |
<cfif q.recordcount> | |
<cfloop query="q"> | |
<cfset stTmp = structNew()> | |
<cfloop list="#lcase(q.columnlist)#" index="col"> | |
<cfset stTmp[col] = q[col][currentRow]> | |
</cfloop> | |
<cfset arrayAppend(aTmp,stTmp)> | |
</cfloop> | |
<cfelse> | |
<cfset stTmp = structNew()> | |
<cfloop list="#lcase(q.columnlist)#" index="col"> | |
<cfset stTmp[col] = ""> | |
</cfloop> | |
<cfset arrayAppend(aTmp,stTmp)> | |
</cfif> | |
<cfreturn aTmp> | |
</cffunction> | |
<cfset aRecordset= querytoarray(qRecordset)> | |
<cfdump var="#aRecordset#"> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment