学说2:树 - 嵌套和InnoDB

时间:2011-08-13 06:22:50

标签: tree nested doctrine-orm behavior

我在MySQL InndoDB数据库中使用Doctrine's 2 Tree-Nestedset extension

yml 表架构如下所示:

Ext\Entity\PageElement:
  type: entity
  table: page_element
  repositoryClass: Gedmo\Tree\Entity\Repository\NestedTreeRepository
  gedmo:
    tree:
      type: nested
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    element_object_data:
      type: array
      nullabe: true
    element_object_type:
      type: string
      nullable: true
    lft:
      type: integer
      gedmo:
        - treeLeft
    rgt:
      type: integer
      gedmo:
        - treeRight
    root:
      type: integer
      gedmo:
        - treeRoot
    lvl:
      type: integer
      gedmo:
        - treeLevel
    sort_order:
      type: integer
      nullable: true
    created:
      type: datetime
      gedmo:
        timestampable:
          on: create
    updated:
      type: datetime
      gedmo:
        timestampable:
          on: update
  manyToOne:
    parent:
      targetEntity: Ext\Entity\PageElement
      inversedBy: children
      gedmo:
        - treeParent
  oneToMany:
    children:
      targetEntity: Ext\Entity\PageElement
      mappedBy: parent

尝试删除包含子节点的任何节点我得到mysql错误:

  

PDOException:SQLSTATE [23000]:完整性约束违规:1451   无法删除或更新父行:外键约束失败   (page_element,CONSTRAINT page_element_ibfk_1 FOREIGN KEY   (parent_id)参考page_elementid))

据我所知,这是因为InnoDB参考限制,但我不确定如何避免它?

1 个答案:

答案 0 :(得分:3)

答案在github issue tracker