|
StructFind
DescriptionDetermines
the value associated with a key in a structure.
ReturnsThe
value associated with a key in a structure; if structure does
not exist, throws an exception.
Function syntaxStructFind(structure, key)
Parameters
Parameter
|
Description
|
structure
|
Structure that contains the value to return
|
key
|
Key whose value to return
|
UsageA structure’s
keys are unordered.
Example<!--- This view-only example shows the use of StructFind. --->
<p>This file is identical to addemployee.cfm, which is called by StructNew,
StructClear, and StructDelete. It adds employees. Employee information
is passed through the employee structure (EMPINFO attribute). In UNIX,
you must also add the Emp_ID.
<!--- <cfswitch expression = "#ThisTag.ExecutionMode#">
<cfcase value = "start">
<cfif StructIsEmpty(attributes.EMPINFO)>
<cfoutput>Error. No employee data was passed.</cfoutput>
<cfexit method = "ExitTag">
<cfelse>
<cfquery name = "AddEmployee" datasource = "cfdocexamples">
INSERT INTO Employees (FirstName, LastName, Email, Phone, Department)
VALUES
<cfoutput>
(
'#StructFind(attributes.EMPINFO, "firstname")#' ,
'#StructFind(attributes.EMPINFO, "lastname")#' ,
'#StructFind(attributes.EMPINFO, "email")#' ,
'#StructFind(attributes.EMPINFO, "phone")#' ,
'#StructFind(attributes.EMPINFO, "department")#' )
</cfoutput>
</cfquery>
</cfif>
<cfoutput><hr>Employee Add Complete</cfoutput>
</cfcase>
</cfswitch> --->
|