如何在Doctrine2 CTI继承中更改和实体类型 [英] How to change and entity type in Doctrine2 CTI Inheritance

查看:146
本文介绍了如何在Doctrine2 CTI继承中更改和实体类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何(如果可能的话)你用Doctrine2改变实体类型,使用它的Class Table Inheritance?

How (if possible at all) do you change the entity type with Doctrine2, using it's Class Table Inheritance?

假设我有一个 Person 父类类型和两个继承类型 Employe Client 。我的系统允许创建一个Person并指定它的类型 - 这是相当容易实现 - 但我也希望能够将人从Employe改为客户端,同时保持 Person -level信息(它的id和其他相关记录)。

Let's say I have a Person parent class type and two inherited types Employe and Client. My system allows to create a Person and specify it's type - that's fairly easy to implement - but I'd also like to be able to change the person from an Employe to a Client, while maintaining the Person-level information (it's id and other associated records).

有一个简单的方法来做这个与Doctrine2?

Is there a simple way to do this with Doctrine2?

推荐答案

我昨天也在寻找这个行为。

I was looking for this behaviour yesterday also.

最后,在与freenode上的#doctrine的人交谈后,我被告知这是不可能的。

In the end, after speaking with people in #doctrine on freenode, I was told that it is not possible.

如果您想这样做,则必须执行以下操作:

If you want to do this, then you have to go through this:


  1. 抓取人员实体。

  2. 更新歧视器列,使其不再是person,并更改为employee。

  3. 在<



删除继承



同样,如果你想删除继承,你必须... ..

Removing Inheritance

Likewise if you want to remove inheritance, you have to..


  1. 获取Person Entity。 >
  2. 更新歧视器列,使其不再是员工,并更改为人员。

  3. 删除 Employee 表。 (是的,你必须删除它,只是更改歧视器列是不够的)。

  1. Grab the Person Entity.
  2. Update the discrimnator column so that it is no longer an 'employee' and change it to a 'person'.
  3. Delete the corresponding row in your Employee table. (Yes you have to delete it, just change the discrimator coumn is not sufficient).

这可能迟了7个月,但至少是正在寻找支持这样的功能的正确答案。

This might be 7 months late, but it is at least the correct answer for anything else looking to suport such a feature.

这篇关于如何在Doctrine2 CTI继承中更改和实体类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆