Macromedia coldfusion 4.5-cfml language reference User Manual
Chapter 2: ColdFusion Functions
523
StructCopy
Returns a new structure with all the keys and values of the specified structure.
See also
StructClear
,
StructDelete
,
StructFind
,
StructInsert
,
StructIsEmpty
,
StructKeyArray
,
StructKeyArray
, and
StructUpdate
.
Syntax
StructCopy(
structure)
structure
Structure to be copied.
Usage
This function throws an exception if structure does not exist.
Example
<!--- This view-only example illustrates usage
of StructCopy. --->
<P>This file is similar to addemployee.cfm, which is called
by StructNew, StructClear, and StructDelete.
<!---
<CFSWITCH EXPRESSION="#ThisTag.ExecutionMode#">
<CFCASE VALUE="start">
<CFIF StructIsEmpty(attributes.EMPINFO)>
<CFOUTPUT>Error. No employee data was passed.</CFOUTPUT>
<CFEXIT METHOD="ExitTag">
<CFELSE>
tempStruct=StructCopy(EMPINFO)
<CFQUERY NAME="AddEmployee" DATASOURCE="cfsnippets">
INSERT INTO Employees
(FirstName, LastName, Email, Phone, Department)
VALUES
<CFOUTPUT>
(
‘#StructFind(attributes.tempStruct, "firstname")#’ ,
‘#StructFind(attributes.tempStruct, "lastname")#’ ,
‘#StructFind(attributes.tempStruct, "email")#’ ,
‘#StructFind(attributes.tempStruct, "phone")#’ ,
‘#StructFind(attributes.tempStruct, "department")#’
)
</CFOUTPUT>
</CFQUERY>
</CFIF>
<CFOUTPUT><hr>Employee Add Complete
<P>#StructCount(attributes.tempStruct)# columns added.
</CFOUTPUT>
</CFCASE>
</CFSWITCH> --->
of StructCopy. --->
<P>This file is similar to addemployee.cfm, which is called
by StructNew, StructClear, and StructDelete.
<!---
<CFSWITCH EXPRESSION="#ThisTag.ExecutionMode#">
<CFCASE VALUE="start">
<CFIF StructIsEmpty(attributes.EMPINFO)>
<CFOUTPUT>Error. No employee data was passed.</CFOUTPUT>
<CFEXIT METHOD="ExitTag">
<CFELSE>
tempStruct=StructCopy(EMPINFO)
<CFQUERY NAME="AddEmployee" DATASOURCE="cfsnippets">
INSERT INTO Employees
(FirstName, LastName, Email, Phone, Department)
VALUES
<CFOUTPUT>
(
‘#StructFind(attributes.tempStruct, "firstname")#’ ,
‘#StructFind(attributes.tempStruct, "lastname")#’ ,
‘#StructFind(attributes.tempStruct, "email")#’ ,
‘#StructFind(attributes.tempStruct, "phone")#’ ,
‘#StructFind(attributes.tempStruct, "department")#’
)
</CFOUTPUT>
</CFQUERY>
</CFIF>
<CFOUTPUT><hr>Employee Add Complete
<P>#StructCount(attributes.tempStruct)# columns added.
</CFOUTPUT>
</CFCASE>
</CFSWITCH> --->