Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 990
Dan Avatar asked Nov 06 '09 12:11

Dan


1 Answers

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

like image 189
Sander Marechal Avatar answered Oct 15 '22 23:10

Sander Marechal