一部のデータを取得するクエリがあります。そのデータをdivタグごとに条件をつけて表示したい。今私の質問は、クエリを 1 回ループし、3 つの異なる構造体でデータを取得し、表示中にこれらの構造体を使用することでこれを行っていることです。これは良いアプローチですか、それとも各 div で毎回クエリをループして条件を確認するのが適切なアプローチですか?
<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