Php 自引用、继承类、如何在使用Doctrine2连接时覆盖公共列值?

Php 自引用、继承类、如何在使用Doctrine2连接时覆盖公共列值?,php,inheritance,orm,doctrine-orm,associations,Php,Inheritance,Orm,Doctrine Orm,Associations,好吧,我这里有点不对劲 我使用的是Symfony2,但更具体地说是ORM,Doctrine2。我把下面的类写成ParameterType: <?php namespace MSS\CMDBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="ParameterType") * @ORM\InheritanceType("JOINED") * @ORM\Dis

好吧,我这里有点不对劲

我使用的是Symfony2,但更具体地说是ORM,Doctrine2。我把下面的类写成
ParameterType

<?php
namespace MSS\CMDBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 *  @ORM\Entity
 *  @ORM\Table(name="ParameterType")
 *  @ORM\InheritanceType("JOINED")
 *  @ORM\DiscriminatorColumn(name="discr", type="string")
 *  @ORM\DiscriminatorMap(
 *      {
 *          "integer" = "IntegerParameterType",
 *          "enumerated" = "EnumeratedParameterType"
 *      })
 */
class ParameterType {
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="string", length=255)
     */
    protected $name;

    /**
     * @ORM\Column(type="integer")
     */
    protected $system;

}

?>
…现在,我经常会得到一个新的
IntegerParameterType
,它只有一个名称和一个基类型。基类型是一个字符串,它引用另一个
IntegerParameterType
(类似于“uchar”或“ushort”)的名称

我要做的是将另一个字段输入标记为“baseType”的
IntegerParameterType
并将字符串存储在我的数据库(MySQL)中。但是,当我想在代码中使用此对象时,我希望该基本
IntegerParameterType
IPT
)的属性与它一起使用(基本上覆盖初始存储在只带有名称和基本类型的
IPT
中的默认值)

到目前为止,我尝试在
IntegerParameterType
中创建一个自引用属性,如下所示:

/**
 * @ORM\ManyToOne(targetEntity="IntegerParameterType")
 * @ORM\JoinColumn(name="baseType", referencedColumnName="name")
 */
protected $baseType;
然而,这不起作用,并且错误会随着
常规错误而消失:1005无法创建表。。。(错误号:150)

如何使该类引用另一个
IntegerParameterType
,并在连接时用另一个对象的值覆盖(如果可能)自身的值

提前谢谢

/**
 * @ORM\ManyToOne(targetEntity="IntegerParameterType")
 * @ORM\JoinColumn(name="baseType", referencedColumnName="name")
 */
protected $baseType;