Data structures ColdFusion:如何检查二维数组中是否存在某个元素?

Data structures ColdFusion:如何检查二维数组中是否存在某个元素?,data-structures,coldfusion,multidimensional-array,Data Structures,Coldfusion,Multidimensional Array,我有一个二维数组。在初始化过程中,我将3个值写入数组,如果数组值与通过表单传递的值不相等,我将添加第四个值。然后我想检查第四个值是否存在 update.cfm <cfset array = obj.getArray() /> <cfif not StructIsEmpty(form)> <cfloop collection="#form#" item="key"> <cfif left(key,3) eq "ID_"> &l

我有一个二维数组。在初始化过程中,我将3个值写入数组,如果数组值与通过表单传递的值不相等,我将添加第四个值。然后我想检查第四个值是否存在

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>

更新表
设定值=
,状态='true'
其中arg=
和数字=
我的错误尝试导致以下错误:

您已尝试将coldfusion.runtime.Array类型的标量变量作为具有成员的结构取消引用


首先,我不是一个巨大的冷聚变人。。。但我很确定不能在数组上使用StructKeyExists,因为它不是结构

还有,你试过类似的东西吗

<cfset testValue = matarray[i][4]>
<cfif isDefined testValue>
    ...
</cfif>

...

我相信您只需要像这样检查数组长度:

<cfif ArrayLen(matarray[i]) gte 4>
      ,status = 'true'
</cfif>

,状态='true'