0
我有cfwheels幾個問題(N:M relationsship)多對多的關係cfwheels內加入
這裏我的數據庫架構
rights righthaspath path
-id -------| -id --> -id
-role -->-rightid (FK) | -url
-pathid (FK)------|
我的模型 /Models/Right.cfc
<cffunction name="init">
<cfset hasMany(name="righthaspath",shortcut="path")>
<cfset nestedProperties(associations="righthaspath")>
</cffunction>
/Models/Path.cfc
<cffunction name="init">
<cfset hasMany(name="righthaspath")>
</cffunction>
/Models/Righthaspath.cfc
<cffunction name="init">
<cfset belongsTo("path")>
<cfset belongsTo("right")>
</cffunction>
在我的控制器
<cfset tmp= model("right").findall(include="righthaspath")>
所以
,從cfhweels sql語句是:
SELECT rights.id,rights.Role,righthaspaths.id AS righthaspathid,righthaspaths.pathID,righthaspaths.rightID FROM rights
LEFT OUTER JOIN righthaspaths ON rights.id = righthaspaths.rightID
,但我想在這三個SQL語句像這樣的桌子
SELECT
*
FROM
rights
INNER JOIN righthaspaths on rights.id=righthaspaths.rightID
INNER JOIN paths on righthaspaths.pathID=paths.id
可以幫忙嗎? PS:我不能包括路徑,例如,我不知道路徑。
<cfset tmp= model("right").findall(include="righthaspath,path")>
,因爲我得到一個錯誤
An association named path could not be found on the right model.
include =「righthaspath(path)」將完成工作 – 2012-04-04 13:17:38
想要將答案張貼爲答案,以便讀者更清楚嗎? – 2012-04-17 20:44:06