Doctrine Symfony项目继承和sfguard
这是我Schema.yml的正确语法吗Doctrine Symfony项目继承和sfguard,doctrine,symfony-1.4,sfguard,Doctrine,Symfony 1.4,Sfguard,这是我Schema.yml的正确语法吗 user_type_1 : inheritance: type: concrete extends: sfGuardUser columns: name: { type: string(255) } user_type_2 : inheritance: type: concrete extends: sfGu
user_type_1 :
inheritance:
type: concrete
extends: sfGuardUser
columns:
name: { type: string(255) }
user_type_2 :
inheritance:
type: concrete
extends: sfGuardUser
columns:
name: { type: string(255) }
我的项目由两种类型的用户user\u type\u 1和user\u type\u 2组成,我希望它们都从sfGuardUser继承,我应该使用继承类型concrete还是column\u aggregation
thx您可以使用任何一种,这取决于您想要什么。 从: 混凝土 具体继承为子类创建单独的表。然而,在具体的继承中,每个类生成一个包含所有列(包括继承列)的表。为了使用具体的继承,您需要向子类添加显式的parent::setTableDefinition调用,如下所示 列聚合 在下面的示例中,我们有一个名为entity的数据库表。用户和组都是实体,它们共享同一个数据库表。 实体表有一个名为type的列,它告诉您实体是组还是用户。然后我们决定用户是类型1,组是类型2。 我们唯一需要做的就是创建3条与以前相同的记录,并从父类添加对Doctrine_Table::setSubclasses方法的调用 使用具体继承将创建2个表user_type_1和user_type_2,而column_聚合将仅创建1个具有“type”列的表