doctrine-ormsingle-table-inheritanceclass-table-inheritance

How to convert entity leaving it id


There are some entities (Region, Country, City) which used STI (or even CTI). How it possible convert Country to City leaving old id?


Solution

  • This is not supported in Doctrine 2 because type casting user objects is not supported by PHP.

    With that said, Doctrine uses the discriminator column to determine what type of object to hydrate. If you change the value of the discriminator column in the database with a SQL UPDATE, the object type will be changed the next time the object is loaded. This works for STI, but CTI would be more complicated.