我有一个二维数组。我在初始化期间将 3 个值写入数组,如果数组值不等于通过表单传递的值,我添加第四个值。然后我想检查第四个值是否存在。
更新.cfm
<cfset array = obj.getArray() />
<cfif not StructIsEmpty(form)>
<cfloop collection="#form#" item="key">
<cfif left(key,3) eq "ID_">
<cfset number = listLast(key,"_") />
<cfset value = evaluate(0,key) />
<cfloop index="j" from="1" to="#arrayLen(array)#">
<cfif (array[j][1] eq number) and (array[j][3] neq value)>
<cfset array[j][3] = value />
<cfset array[j][4] = "true" />
</cfif>
</cfloop>
</cfif>
</cfloop>
<cfset obj = createObject("component", "cfc.Obj").init(arg = form.arg, argarray = array) />
<cfset application.objDao.update(obj) />
objDao.cfc 更新方法
<cfset matarray = arguments.obj.getArray() />
<cfloop index="i" from="1" to="#arrayLen(array)#">
<cfquery name="qUpdateAsset" datasource="#variables.instance.dsn#">
UPDATE table
SET value = <cfqueryparam value="#matarray[i][3]#" cfsqltype="cf_sql_integer" />
<!--- This is wrong, how do i check the existence correctly? --->
<cfif StructKeyExists(matarray[i],"4")>
,status = 'true'
</cfif>
WHERE arg = <cfqueryparam value="#arguments.obj.getArg()#" cfsqltype="cf_sql_smallint" />
AND number = <cfqueryparam value="#matarray[i][1]#" cfsqltype="cf_sql_integer" />
</cfquery>
</cfloop>
我的错误尝试导致此错误:
您试图取消引用类型为coldfusion.runtime.Array 的标量变量作为具有成员的结构。