STRUCTINSERT  
説明

キーと値のペアを構造体に挿入します。

 
戻り値

正常に完了した場合は true。structure が存在しない場合、または key が既に存在して allowoverwrite = "False" の場合は、例外が発生します。

 
カテゴリ

構造体関数

 
関数のシンタックス
StructInsert(structure, key, value [, allowoverwrite ])
 
関連項目

構造体関数、『ColdFusion MX 開発ガイド』の第35章の「XML および WDDX の使用」 の「ColdFusion XML オブジェクトの変更」

 
ヒストリ

ColdFusion MX: 動作の変更 : この関数は、XML オブジェクトに使用できます。

 
パラメータ

 
使用方法

構造体のキーはソートされていません。

 
<h1>新しい従業員の追加</h1>
<!--- パラメータの初期値を設定 --->
<cfparam name = "FORM.firstname" default = "">
<cfparam name = "FORM.lastname" default = "">
<cfparam name = "FORM.email" default = "">
<cfparam name = "FORM.phone" default = "">
<cfparam name = "FORM.department" default = ""> 

<cfif FORM.firstname EQ "">
 <p>フォームの各項目を入力してください。
<cfelse>
 <cfoutput>
  <CFScript>
   employee = StructNew();
   StructInsert(employee, "firstname", FORM.firstname);
   StructInsert(employee, "lastname", FORM.lastname);
   StructInsert(employee, "email", FORM.email);
   StructInsert(employee, "phone", FORM.phone);
   StructInsert(employee, "department", FORM.department);
 </CFScript> 

 <p>名前 : #StructFind(employee, "firstname")#</p>
 <p>姓 : #StructFind(employee, "lastname")#</p>
 <p>電子メール : #StructFind(employee, "email")#</p>
 <p>電話番号 : #StructFind(employee, "phone")#</p>
 <p>部門 : #StructFind(employee, "department")#</p>
 </cfoutput>

 <!--- 従業員を追加するカスタムタグを呼び出します。 --->
 <CF_ADDEMPLOYEE EMPINFO = "#employee#">
</cfif>

<Hr>
<form action = "structinsert.cfm">
   <p>名前 :&nbsp;
   <input name = "firstname" type = "text" hspace = "30" maxlength = "30">
   <p>姓 :&nbsp;
   <input name = "lastname" type = "text" hspace = "30" maxlength = "30">
   <p>電子メール :&nbsp;
   <input name = "email" type = "text" hspace = "30" maxlength = "30">
   <p>電話番号 :&nbsp;
   <input name = "phone" type = "text" hspace = "20" maxlength = "20">
   <p>部門 :&nbsp;
   <input name = "department" type = "text" hspace = "30" maxlength = "30">
   <p>
   <input type = "submit" value = "OK">
</form>
STRUCTURE  
新しいキーと値のペアを挿入する構造体です。
KEY  
挿入する値を持つキーです。
VALUE  
挿入する値です。
ALLOWOVERWRITE  
オプションです。既存のキーへの上書きを認めるかどうかを指定します。デフォルト値は false です。