我有一個查詢檢索一些數據。 我想在不同的div標籤中考慮一些條件來顯示這些數據。 現在我的問題是, 我通過循環查詢一次,獲取三個不同結構中的數據並在顯示時使用這些結構來完成此操作。這是一個很好的方法或 在每個div中每次循環查詢來檢查條件是rip方法嗎?循環遍歷一個Cfquery或Struct?
<tr >
<td >
features:
</td>
<td >
<cfloop query="getAttributes">
<cfif getAttributes.type_id EQ 1>
#getAttributes.seat#<br>
</cfif>
</cfloop>
</td>
</tr>
<tr>
<td >
Disclosures:
</td>
<td >
<cfloop query="getAttributes">
<cfif getAttributes.type_id EQ 2>
#getTicketAttributes.seat#<br>
</cfif>
</cfloop>
</td>
</tr>
或者我可以使用下面的方法
seatStruct
disclosureStruct
<cfloop query="getAttributes">
<cfif getAttributes.type_id EQ 1>
Insert seatStruct
<cfelseif getAttributes.type_id EQ 2>
insert disclosureStruct
</cfif>
Now use these structs to display
嗨,我已經添加了代碼。而不是做上述的方式,我可以得到兩個差異結構中的內容,並使用它們 ? 喜歡... seatStruct disclosureStruct 插入seatStruct 插入disclosureStruct 現在使用這些結構顯示。 –
Somu
2010-05-06 07:06:21
你也可以做查詢的查詢: \t選擇\t \t FROM \t的getAttributes \t WHERE \t TYPE_ID = 2 和同爲TYPE_ID = 1 所以再次沒有必要轉換爲結構。 –
2010-05-06 08:32:23
好的,這是否意味着查詢是最好的方式而不是使用結構? – Somu 2010-05-06 10:03:55