我正在转换到Cold聚变的ORM,并想知道如何使用ORM复制cfoutput的分组?
我得到了以下错误:Can't cast Object type [java.util.ArrayList] to a value of type [query]
查询:
qryGames = ormExecuteQuery("from Game where Season.seasonID=:sid and League.leagueID=:lid and Season.User.userID=:uid order by League.leagueName, GameType.gameTypeID, gameDate DESC", {sid=url.sid, lid=leagueID, uid=session.userID});代码:
<cfif arraylen(qryGames) GT 0>
<cfoutput query="qryGames" group="leagueName">
<cfoutput group="gameTypeName">
...
</cfoutput>
</cfoutput>
</cfif>我看不到cfloop的分组属性。我总是可以手动复制它,但我想知道是否有一个内置的方式来做到这一点。
更新#1
使用entityToQuery
qryGames = entityToQuery(ormExecuteQuery("from Game where Season.seasonID=:sid and League.leagueID=:lid and Season.User.userID=:uid order by League.leagueName, GameType.gameTypeID, gameDate DESC", {sid=url.sid, lid=leagueID, uid=session.userID}), "League");我得到以下错误:
Message column [gameTypeName] not found in query, columns are [leagueID,leagueName,leagueAbbr,teamName,gameInMinutes,deleteYN,showReportYN]只限于一个实体的名字?
发布于 2015-11-20 19:13:00
先使用EntityToQuery() http://cfdocs.org/entitytoquery,然后再使用<cfoutput query=
发布于 2015-11-20 18:49:06
您的结果集不是查询,而是数组,必须以查询的形式循环。
<cfloop array="#games#" index="game">
<!--- do stuff --->
</cfloop>至于复制可用于查询的内置分组功能,我不认为有一种自动处理数组的方法,因此您需要在组中编写逻辑来执行分组,或者需要在返回结果后将结果拆分,然后用不同的循环在不同的部分上循环。
https://stackoverflow.com/questions/33833724
复制相似问题