0
任何人都可以给我一个如何实现类自我关系的例子吗?实现自我关系
任何人都可以给我一个如何实现类自我关系的例子吗?实现自我关系
你需要的东西是这样的:
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
的正是你想做的事更多信息请。 – 2009-11-30 18:49:12