Adobe COLDFUSION 9 Manual page 110

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
<cfif StructIsEmpty(attributes.empinfo)>
<cfoutput>
Error. No employee data was passed.<br>
</cfoutput>
<cfexit method="ExitTag">
<cfelse>
<!--- Add the employee --->
<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>
<cfoutput>
<hr>Employee Add Complete
</cfoutput>
Reviewing the code
The following table describes the code:
Code
<cfif StructIsEmpty(attributes.empinfo)>
<cfoutput>
Error. No employee data was passed.<br>
</cfoutput>
<cfexit method="ExitTag">
<cfelse>
<!--- Add the employee --->
<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>
<cfoutput>
<hr>Employee Add Complete
</cfoutput>
Structure functions
You can use the following functions to create and manage structures in ColdFusion applications. The table describes
the purpose of each function and provides specific, but limited, information that can assist you in determining whether
to use the function instead of other technique.
All functions except
StructDelete
For more information on these functions, see the CFML Reference.
Description
If the custom tag was called without an
displays an error message and exit the tag.
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, add an Emp_ID entry to the form and add it to the
query.
Display a completion message. This code does not have to be
inside the
being run if the empinfo structure is empty.
throw an exception if a referenced key or structure does not exist.
Last updated 8/5/2010
empinfo
cfelse
block because the cfexit tag prevents it from
105
attribute,

Advertisement

Table of Contents
loading

Table of Contents