home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / structupdate.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.7 KB  |  41 lines

  1. <!--- This view-only example illustrates usage
  2.       of StructUpdate. --->
  3. <P>This file is similar to addemployee.cfm, which is called
  4. by StructNew, StructClear, and StructDelete. To test this file,
  5. copy the <cfelseif> statement to the appropriate place
  6. in addemployee.cfm. It is an example of a custom tag used 
  7. to add employees. Employee information is passed through the 
  8. employee structure (the EMPINFO attribute). 
  9. <P>
  10. To run this snippet
  11. under UNIX, you must add employee ID generation logic.
  12. <!--- 
  13. <cfswitch expression="#ThisTag.ExecutionMode#">
  14.    <cfcase value="start">
  15.       <CFIF StructIsEmpty(attributes.EMPINFO)>
  16.         <CFOUTPUT>Error. No employee data was passed.</cfoutput>
  17.           <CFEXIT METHOD="ExitTag">
  18.         <cfelseif StructFind(attributes.EMPINFO, "department") EQ "">
  19.           <cfscript>
  20.             StructUpdate(attributes.EMPINFO, "department", "Unassigned");
  21.           </cfscript>
  22.           <CFEXIT METHOD="ExitTag">
  23.         <cfelse>            
  24.           <CFQUERY NAME="AddEmployee" DATASOURCE="cfsnippets">
  25.             INSERT INTO Employees(FirstName, LastName, Email, Phone, Department)
  26.               VALUES 
  27.                 <CFOUTPUT>
  28.                   (
  29.                     '#StructFind(attributes.EMPINFO, "firstname")#' ,
  30.                     '#StructFind(attributes.EMPINFO, "lastname")#' ,
  31.                     '#StructFind(attributes.EMPINFO, "email")#' ,
  32.                     '#StructFind(attributes.EMPINFO, "phone")#' ,
  33.                     '#StructFind(attributes.EMPINFO, "department")#'
  34.                    )
  35.                 </cfoutput> 
  36.           </cfquery>
  37.         </cfif>
  38.       <CFOUTPUT><HR>Employee Add Complete</CFOUTPUT>
  39.    </cfcase>
  40. </cfswitch> --->
  41.