2011-11-05 4 views
0

두 테이블 - usersstores이 있습니다.
관계 (HABTM)를 관리해야하는 세 번째 테이블 인 stores_users이 있습니다.cakePHP와 같은 테이블 간의 여러 유형의 관계

그러나 저장소에는 저장소 소유자 (belongsTo)를 만든 사람인 저장소 소유자를 나타내는 user_id 열이 있습니다.
이 사용자는 다른 사용자에게 관리 권한을 부여 할 수 있습니다 ..

이 관계 때문에 문제가 발생합니까?

답변

1

이것은 문제가되지 않습니다. 당신은

array(
    [Store] => array(...) 
    [Creator] => array(...) 
    [Manager] => array(
     0 => array(...) 
     1 => array(...) 
    ) 
)  
+0

대답 주셔서 감사합니다 같은 데이터를 반환합니다 Store에서 지금

class Store extends AppModel { public $belongsTo = array( 'Creator' => array( 'className' => 'User', 'foreignKey' => 'user_id', ), ); public $hasAndBelongsToMany = array( 'Manager' => array( 'className' => 'User', 'joinTable' => 'stores_users', 'foreignKey' => 'store_id', 'associationForeignKey' => 'user_id', ), ); } 

같은 find 작업로 협회에 별칭을 줄 수 있습니다! – yossi