[FLOW3-general] Abstract classes and extending objects

Dawid Pacholczyk dpacholczyk at gmail.com
Fri Aug 26 23:39:22 CEST 2011


For me it`s creating 3 tables :/

1 for abstract class and 2 for classes that are extending it. I`m doing 
like you based on doctrine documentation

W dniu 2011-08-18 01:11, Zach Davis pisze:
> I'm not positive this is what you're trying to do, but this worked for me:
>
> /**
> * @scope prototype
> * @entity
> * @InheritanceType("SINGLE_TABLE")
> * @DiscriminatorColumn(name="type", type="string")
> * @DiscriminatorMap({"AccountIndividual" = "AccountIndividual",
> "AccountOrganization" = "AccountOrganization"})
> */
> class Account {
> }
>
> /**
> * @scope prototype
> * @entity
> */
> class AccountIndividual extends Account {
> }
>
> /**
> * @scope prototype
> * @entity
> */
> class AccountOrganization extends Account {
> }
>
> With these annotations, Doctrine seems to be able to store both types in
> the same table (and they also both get stored in the same repository,
> which was useful for my purposes).
>
> best,
> Zach
>
>
>
>
> Dawid Pacholczyk wrote:
>> Hello List,
>> I want to talk about one thing.
>>
>> For example I have 2 objects:
>> -> Soldier
>> -> Salesman
>>
>> They are diffrent persons but they have something in common like name,
>> surname, age etc
>>
>> but also some diffrent thing like for example Soldier have a rank or
>> Salesman got salary
>>
>> Now I would like to create ABSTRACT class Person and create normal
>> classes Soldier and Salesman that will extend Person. How can I do that ?
>>
>> Should I just create normal models (but one as abstract class) and use
>> standard adnotations to map object ? How can I extend an object via
>> doctrine ?
>>
>> Best regards,
>> Dawid Pacholczyk



More information about the FLOW3-general mailing list