Symfony2 / Doctrine manyToOne-relationship不会出现在表中

时间:2012-06-04 21:04:21

标签: symfony doctrine many-to-one

我正在使用Doctrine架构,但遇到了麻烦,因为manyToOne关系中的一个不会在数据库中持久存在。我很无能为什么会这样,因为在我看来,语法看起来是正确的。

任何人都可以发现问题吗?

以下是我在yaml中的架构。运行后,我的mysql数据库中没有关于这两个实体的表 php app\console doctrine:schema:update --force

Me\MyBundle\Entity\FreeTextField:
  type: entity
  table: null
  fields:
    id:
      type: integer
      id: true
      generator:
        strategy: AUTO
    name:
      type: string
    flagPrivate:
      type: boolean
    description:
      type: text
      nullable: TRUE
  oneToMany:
    entries:
      targetEntity: FreeTextEntry
      mappedBy: xfield

  lifecycleCallbacks: {  }

Me\MyBundle\Entity\FreeTextEntry:
  type: entity
  table: null
  fields:
    id:
      type: integer
      id: true
      generator:
        strategy: AUTO
    content:
      type: text

  manyToOne:
    xfield:
      targetEntity: FreeTextField
      inversedBy: entries
  manyToOne:
    registration:
      targetEntity: Registration
      inversedBy: freeTextEntries
  lifecycleCallbacks: {  }

1 个答案:

答案 0 :(得分:1)

here相同的问题。您需要将所有manyToOne类型关联放在Entity \ FreeTextEntry中的相同类型声明下,如下所示:

manyToOne:
  xfield:
    targetEntity: FreeTextField
    inversedBy: entries
  registration:
    targetEntity: Registration
    inversedBy: freeTextEntries