2009-11-30 4 views
0

누구든지 나에게 클래스 자체 관계를 구현하는 방법에 대한 예제를 줄 수 있습니까?자체 관계 구현

+0

더 많은 정보 부디. –

답변

1

는이 같은 뭔가가 필요 :

MenuOption: 
    tableName: MenuOption 
    columns: 
    id: 
     type: integer(4) 
     autoincrement: true 
    child_menu_option_id: 
     type: integer(4) 
     null: true 
    ... (more columns) 
    relations: 
    ChildMenuOptions: 
     class: MenuOption 
     foreignAlias: News 
     foreign: id 
     local: child_menu_option_id 
당신이 MenuOption 객체를로드 한 후에는 다음과 같이 자녀를 참조 것

:

$menuOption = Doctrine_Query::create() 
    ->from("MenuOption") 
    ->where("stuff here") 
    ->fetchOne(); 
$children = $menuOption->ChildMenuOptions; // this will be a Doctrine_Collection object 
정확히 당신이 원하는 무엇에