Я не могу выполнить загрузку данных (доктрина Symfony 1.4)

У меня есть некоторые проблемы с моим проектом Symfony.
У меня есть база данных MySQL с таблицами InnoDB.
Я пытаюсь создать простое дерево-меню:

schema.yml

Menu:
  actAs:
    Timestampable:
      created:
        disabled: true
      updated:
        disabled: true
  columns:
    id: { type: integer, autoincrement: true, notnull: true, primary: true }
    name: { type: string(255), notnull: true }
    parent: { type: integer, notnull: false }
  relations:
    Parent:
      alias: parentItem
      foreignAlias: childrens
      class: Menu
      local: parent
      foreign: id
      type: many-to-one
      onDelete: CASCADE

После создания элементов в бэкэнде я выполняю data:dump и получите этот код

крепление:

Menu:
  Menu_1:
    name: 'Parent'
  Menu_2:
    parentItem: Menu_1
    name: 'Children'

Если я попытаюсь бежать, я потерял отношения между предметами

Я не понимаю, что не так.

Редактировать:

До:

| id | name     | parent |
| 1  | Parent   | NULL   |
| 2  | Children | 1      |

После

| id | name     | parent |
| 1  | Parent   | NULL   |
| 2  | Children | 0      |

1 ответ

Я думаю, что тип отношений один, а внешний тип отношений много:

Menu:
  actAs:
    Timestampable:
      created:
        disabled: true
      updated:
        disabled: true
  columns:
    id: { type: integer, autoincrement: true, notnull: true, primary: true }
    name: { type: string(255), notnull: true }
    parent: { type: integer, notnull: false }
  relations:
    Parent:
      alias: parentItem
      class: Menu
      local: parent
      foreign: id
      type: one
      foreignAlias: childrens
      foreignType: many
      onDelete: CASCADE
Другие вопросы по тегам