我正在寻找循环查询,并想使用分组,就像使用cfoutput
. 我知道 CF10 添加了该支持,但是是否有模拟该行为的脚本以便可以轻松地迭代项目?
编辑:cfloop
有一些方法可以通过重新排列标签
来解决缺少分组的问题cfoutput
,因此它们不是嵌套的。我正在寻找cfloop
解决方法的原因是嵌套时cfoutput
,您需要使用来自同一查询的结果。我想使用我自己的 QoQ 并循环查看结果。
我正在寻找循环查询,并想使用分组,就像使用cfoutput
. 我知道 CF10 添加了该支持,但是是否有模拟该行为的脚本以便可以轻松地迭代项目?
编辑:cfloop
有一些方法可以通过重新排列标签
来解决缺少分组的问题cfoutput
,因此它们不是嵌套的。我正在寻找cfloop
解决方法的原因是嵌套时cfoutput
,您需要使用来自同一查询的结果。我想使用我自己的 QoQ 并循环查看结果。
好的,所以你想做这样的事情:
<cfoutput query="query1">
<!--- stuff --->
<cfoutput query="query2" group="col>
<!--- more stuff --->
<cfoutput>
<!--- still more stuff --->
</cfoutput>
<!--- almost the last stuff --->
</cfoutput>
<!--- last stuff --->
</cfoutput>
?
第二个循环给你一个错误:
Invalid tag nesting configuration.
A query driven cfoutput tag is nested inside a cfoutput tag that also has a query attribute. This is not allowed. Nesting these tags implies that you want to use grouped processing. However, only the top-level tag can specify the query that drives the processing.
您应该能够将其修改为:
<cfloop query="query1">
<cfoutput>
<!--- stuff --->
</cfoutput>
<cfoutput query="query2" group="col>
<!--- more stuff --->
<cfoutput>
<!--- still more stuff --->
</cfoutput>
<!--- almost the last stuff --->
</cfoutput>
<cfoutput>
<!--- last stuff --->
</cfoutput>
</cfloop>
如果必须,还有另一个选项可以模拟组循环。但这是一堆思考和打字,如果可能的话,我宁愿避免,所以让我知道这种方法是否首先有效。