home *** CD-ROM | disk | FTP | other *** search
- <!--- This is an example of a custom tag used
- to add employees. Employee information is passed
- through the employee structure (the EMPINFO attribute. --->
- <!---
- This is a read-only example, because access to a database
- is a sensitive area. Consider the security of your database before
- allowing access to it.
-
- <cfswitch expression="#ThisTag.ExecutionMode#">
- <cfcase value="start">
- <CFIF StructIsEmpty(attributes.EMPINFO)>
- <CFOUTPUT>Error. No employee data was passed.</cfoutput>
- <CFEXIT METHOD="ExitTag">
- <cfelse>
- <!--- Add the employee --->
- <!--- In UNIX, you must also insert the Emp_ID (Long) --->
- <CFQUERY NAME="AddEmployee" datasource="cfsnippets">
- <CFIF Server.OS.Name EQ "Windows NT">
- 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>
- <CFELSE>
- INSERT INTO Employees(Emp_ID, FirstName, LastName, EMail, Phone, Department)
- VALUES
- <CFOUTPUT>
- (
- '#StructFind(attributes.EMPINFO, "empid")#' ,
- '#StructFind(attributes.EMPINFO, "firstname")#' ,
- '#StructFind(attributes.EMPINFO, "lastname")#' ,
- '#StructFind(attributes.EMPINFO, "email")#' ,
- '#StructFind(attributes.EMPINFO, "phone")#' ,
- '#StructFind(attributes.EMPINFO, "department")#'
- )
- </cfoutput>
- </cfif>
- </cfquery>
- </cfif>
- <CFOUTPUT><HR>Employee Add Complete</cfoutput>
- </cfcase>
- </cfswitch>
-
- --->