私は2次元配列を持っています。初期化中に3つの値を配列に書き込み、配列の値がフォームを介して渡される値と等しくない場合は、4番目の値を追加します。次に、4番目の値が存在するかどうかを確認します。
update.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型のスカラー変数をメンバーを持つ構造体として逆参照しようとしました。