data structures - ColdFusion: How to check if a certain element exists in a 2-dimensional array? -


I have a 2 dimensional array. I write 3 values ​​in the array during my initialization and add a quarter value if An array value is not equal to the value passed through a form. Then I want to check if the fourth value is present.

update.cfm

  & lt; Cfset array = obj.getArray () /> & Lt; Cfif no StructIsEmpty (form) & gt; & Lt; Cfloop collection = "#form #" item = "key" & gt; & Lt; Cfif left (key, 3) eq "ID_" & gt; & Lt; Cfset number = listLast (key, "_") /> & Lt; Cfset value = evaluation (0, key) /> & Lt; Cfloop index = "j" = "1" from "# arraylen (array) #" & gt; & Lt; Cfif (array [j] [1] eac number) and (array [j] [3] neb value) & gt; & Lt; Cfset array [j] [3] = value / & gt; & Lt; Cfset array [j] [4] = "true" /> & lt; / Cfif> & Lt; / Cfloop & gt; & Lt; / Cfif> & Lt; / Cfloop & gt; & Lt; Cfset obj = createObject ("component", "cfc.Obj"). Init (arg = form.arg, argarray = array) /> & Lt; Cfset application.objDao.update (obj) />  

objDao.cfc update method

  & lt; Cfset matarray = arguments.obj.getArray () /> & Lt; Cfloop index = "i" = "1" from "# arraylining (array) #" & gt; & Lt; Cfquery name = "qUpdateAsset" data source = "# variables.instance.dsn #" & gt; Update table SET value = & lt; Cfqueryparam value = "#mitterre [i] [3] #" cfsqltype = "cf_sql_integer" /> & Lt ;! --- This is wrong, how do I check the existence of the right way? --- & gt; & Lt; Cfif StructKeyExists (Marter [i], "4") & gt; , Condition = 'true' & lt; / Cfif> WHERE arg = & lt; Cfqueryparam value = "# arguments.object.art22 () #" cfsqltype = "cf_sql_smallint" /> And number = & lt; Cfqueryparam value = "#mitterre [i] [1] #" cfsqltype = "cf_sacl_i_tiger" /> & lt; / Cfquery & gt; & Lt; / Cfloop & gt;  

This error is the result of my wrong endeavor:

You have tried to dereference the scalar variable of class squared cooling. .

I believe that you only need to check the array length:

  & lt; Cfif ArrayLen (matarray [i]) gte 4 & gt; , Condition = 'true' & lt; / Cfif>  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -