Created
March 26, 2012 12:56
-
-
Save nkostic/2204871 to your computer and use it in GitHub Desktop.
Convert Array Of Structures To Query
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="ArrayOfStructuresToQuery" access="public" returntype="query" output="false"> | |
<cfargument name="StructArray" type="any" required="true" /> | |
<cfscript> | |
KeyList=StructKeyList(arguments.StructArray[1]); | |
qbook = QueryNew(KeyList); | |
for(i=1; i <= ArrayLen(arguments.StructArray); i=i+1){ | |
QueryAddRow(qbook); | |
for(y=1;y lte ListLen(KeyList);y=y+1){ | |
QuerySetCell(qbook, ListGetAt(KeyList,y), arguments.StructArray[i][ListGetAt(KeyList,y)]); | |
} | |
} | |
return qbook; | |
</cfscript> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems not to work with ColdFusion 11? I migrated to CF11 and it broke the use of this UDF:
"Element is undefined in a CFML structure referenced as part of an expression."
Seems to be thrown when this is happening:
querySetCell(theQuery, colNames[j], theArray[i][colNames[j]], i);