User Guide

Table Of Contents
Structure functions 121
<cfoutput>
<hr>Employee Add Complete
</cfoutput>
Reviewing the code
The following table describes the code:
Structure functions
You can use the following functions to create and manage structures in ColdFusion applications.
The table describes each functions purpose and provides specific, but limited, information that
can assist you in determining whether to use the function instead of other techniques:
Code Description
<cfif StructIsEmpty(Attributes.empinfo)>
<cfoutput>
Error. No employee data was passed.
</cfoutput>
<cfexit method="ExitTag">
If the custom tag was called without an
empinfo attribute, display an error message
and exit the tag.
<cfelse>
<cfquery name="AddEmployee" datasource=
"cfdocexamples">
INSERT INTO Employees
(FirstName, LastName, Email, Phone,
Department)
VALUES (
'#attributes.empinfo.firstname#' ,
'#attributes.empinfo.lastname#' ,
'#attributes.empinfo.email#' ,
'#attributes.empinfo.phone#' ,
'#attributes.empinfo.department#' )
</cfquery>
</cfif>
Add the employee data passed in the empinfo
structure to the Employees table of the
cfdocexamples database.
Use direct references to the structure entries,
not
StructFind functions.
If the database does not support automatic
generation of the Emp_ID key, you must add
an Emp_ID entry to the form and add it to the
query.
<cfoutput>
<hr>Employee Add Complete
</cfoutput>
Display a completion message. This code
does not have to be inside the
cfelse block
because the
cfexit tag prevents it from being
run if the empinfo structure is empty.
Function Description
Duplicate Returns a complete copy of the structure.
IsStruct Returns True if the specified variable is a ColdFusion structure or a Java
object that implements the java.util.Map interface.
StructAppend Appends one structure to another.
StructClear Removes all data from the specified structure.
StructCopy Returns a "shallow" copy of the structure. All embedded objects are
references to the objects in the original structure. The
Duplicate function
has replaced this function for most purposes.
StructCount Returns the number of keys in the specified structure.