Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cffunction name="updateCompoundWithNonPK" returntype="void" access="public" output="false" hint="I update a relation table that has a non-PK field">
- <cfargument name="Tablename" type="string" required="true">
- <cfargument name="CompoundPivotField" type="string" required="true">
- <cfargument name="CompoundPivotValue" type="string" required="true">
- <cfargument name="CompoundMultiField" type="string" required="true">
- <cfargument name="CompoundMultiValue" type="string" required="true">
- <cfargument name="NonPKField" type="string" required="true">
- <cfargument name="NonPKValue" type="string" required="true">
- <cfset var sUpdate = StructNew()>
- <cfset var sExisting = StructNew()>
- <cfset var ExistingList = "">
- <cfset var qExistingRecords = 0>
- <cfset var IncomingCompoundMultiValue = arguments.CompoundMultiValue>
- <cfset var debugoutput = "">
- <!--- First, handle the list relation update --->
- <cfset sExisting[CompoundPivotField] = CompoundPivotValue>
- <cfset qExistingRecords = getRecords(tablename=arguments.Tablename,data=sExisting)>
- <cfif qExistingRecords.RecordCount>
- <cfoutput query="qExistingRecords">
- <cfset ExistingList = ListAppend(ExistingList,qExistingRecords[arguments.CompoundMultiField][CurrentRow])>
- </cfoutput>
- <cfset arguments.CompoundMultiValue = ListAppend(arguments.CompoundMultiValue,ExistingList)>
- </cfif>
- <cfif arguments.tablename EQ "cfsTopicsMandatory2Locations" AND qExistingRecords.RecordCount>
- <cffile action="append" file="/home/timd/git/cfs-new/f/ajax/debug.cfm" output="Called at #now()#. ">
- </cfif>
- <cftry>
- <cfset saveRelationList(arguments.Tablename,arguments.CompoundPivotField,arguments.CompoundPivotValue,arguments.CompoundMultiField,arguments.CompoundMultiValue)>
- <cfcatch>
- <cfsavecontent variable="debugoutput">
- <cfdump var="#cfcatch#">
- </cfsavecontent>
- <cffile action="append" file="/home/timd/git/cfs-new/f/ajax/debug.cfm" output="ERROR:Called at #now()#.<br>#debugoutput#">
- </cfcatch>
- </cftry>
- <!--- Now, we can do a simple save to add the non-PK value --->
- <cfset sUpdate[arguments.CompoundPivotField] = arguments.CompoundPivotValue>
- <cfset sUpdate[arguments.CompoundMultiField] = IncomingCompoundMultiValue>
- <cfset sUpdate[arguments.NonPKField] = arguments.NonPKValue>
- <cfset saveRecord(tablename=arguments.Tablename,data=sUpdate)>
- </cffunction>
Add Comment
Please, Sign In to add comment