Return to Snippet

Revision: 59168
at August 22, 2012 05:09 by daspoda


Initial Code
<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>

Initial URL


Initial Description
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

Initial Title
renameForCompositeKey

Initial Tags


Initial Language
ColdFusion