Skip to content

Instantly share code, notes, and snippets.

@acotie
Created March 2, 2010 09:11
Show Gist options
  • Save acotie/319371 to your computer and use it in GitHub Desktop.
Save acotie/319371 to your computer and use it in GitHub Desktop.
<cffunction name="QueryToStructArray" access="private" returntype="array" output="no" hint="convert to Array of query to Struct.">
<cfargument name="query" type="query" required="yes">
<cfargument name="rownum" type="numeric" default="1">
<cfset var local = StructNew()>
<cfset local.result = ArrayNew(1)>
<cfif arguments.query.RecordCount gte 1>
<cfloop index="local.i" from="1" to="#arguments.query.RecordCount#">
<cfset local.obj = createObject("component","componentFile")>
<cfloop index="local.col" list="#arguments.query.ColumnList#">
<cfset local.obj[local.col] = arguments.query[local.col][local.i]>
</cfloop>
<cfset local.result[local.i] = local.obj>
</cfloop>
</cfif>
<cfreturn local.result>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment