Dan
Dan

Reputation: 4140

PHP Doctrine Inheritance

I'm reading through the Doctrine documentation but I can't find a way to implement the type of inheritance I want to use.

I would like to set up a hierarchy like so:

Node -> Something -> Something Else

With Node being the main parent.

I would like to store data common to everything in a node table, eg date of creation, update etc rather than storing this same information in every table. The child classes would then have varying properties depending on their purposes.

Doctrine's simple and column_aggregation methods do not appear to be able to create new tables for the child classes, whilst the concrete method makes a new table but copies all of the parent's properties.

Is there a way to achieve this?

Any advice appreciated.

Thanks.

Upvotes: 6

Views: 921

Answers (1)

Sander Marechal
Sander Marechal

Reputation: 23216

Doctrine 2.x supports class table inheritance, which is what you want here.

Upvotes: 1

Related Questions