2012-04-04 9 views
0

ich ein paar Probleme mit cfwheels haben (n: m relationsship)viele zu viele Beziehung cfwheels Exklusionsverknüpfung

hier meine Datenbankschema

rights  righthaspath   path   
-id -------| -id    --> -id 
-role  -->-rightid (FK)  | -url 
       -pathid (FK)------| 

meine Modelle /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> 

in meinem Controller-

<cfset tmp= model("right").findall(include="righthaspath")> 

so ist die SQL-Anweisung von cfhweels:

SELECT rights.id,rights.Role,righthaspaths.id AS righthaspathid,righthaspaths.pathID,righthaspaths.rightID FROM rights 
LEFT OUTER JOIN righthaspaths ON rights.id = righthaspaths.rightID 

, aber ich möchte eine SQL-Anweisung über die drei Tabellen wie diese

SELECT 
    * 
FROM 
    rights 
    INNER JOIN righthaspaths on rights.id=righthaspaths.rightID 
    INNER JOIN paths on righthaspaths.pathID=paths.id 

können Sie helfen?

PS: Ich kann Pfad nicht einschließen, z.

<cfset tmp= model("right").findall(include="righthaspath,path")> 

, weil ich einen Fehler bekam

An association named path could not be found on the right model. 
+0

include = "righthaspath (Pfad)" funktioniert –

+0

Möchten Sie Ihre Antwort als Antwort posten, so dass es für die Leser klarer ist? –

Antwort

0

Im Namen von Hans Maeier oben, ich werde seine Antwort posten, damit es als beantwortet markiert werden kann und die CFWheels Gemeinschaft auf Stackoverflow unterstützen.

include = "righthaspath (Pfad)" wird

Hoffnung getan Arbeit, die jemand für diese Suche hilft.

Danke, Michael.