/ Published in: ColdFusion
RenameForCompositeKey
Helps with creating new composite key objects by renaming the keys to include a blank id
@structure, structure to rename keys on
@keyPosition, position of the provided key
Helps with creating new composite key objects by renaming the keys to include a blank id
@structure, structure to rename keys on
@keyPosition, position of the provided key
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<cffunction name="renameForCompositeKey" returntype="struct"> <cfargument name="structure" required="yes"> <cfargument name="keyPosition" required="yes" type="numeric"> <cfset LOCAL = StructNew()> <!--- create temporary structure copy ---> <cfset LOCAL.temp = structure> <!--- clear structure ---> <cfset structure = StructNew()> <!--- loop through keys, and repopulate struct ---> <cfloop collection="#LOCAL.temp#" item="key"> <cfif keyPosition EQ 1> <cfset structure["#key#,"] = LOCAL.temp[key]> <cfelse> <cfset structure[",#key#"] = LOCAL.temp[key]> </cfif> </cfloop> <cfreturn structure> </cffunction>