我有一个查询检索一些数据。 我想在不同的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