Php 记录更新时丢失的条令关系

Php 记录更新时丢失的条令关系,php,mysql,symfony1,doctrine,Php,Mysql,Symfony1,Doctrine,我使用的是Symfony和document,并且有好几个多对多的关系 但是有一个名为document的表,它包含可以与多种内容相关的文档,并且有自己的管理部分 每当我更新文档时,它与其他表的所有关系都会丢失 我在谷歌上搜索了一会儿,但找不到原因 你有没有经历过这样的事情?我能做什么 这是模式,但MySQL中不存在约束 Document: actAs: [Timestampable] columns: title: string(255) filename: string(

我使用的是Symfony和document,并且有好几个多对多的关系

但是有一个名为document的表,它包含可以与多种内容相关的文档,并且有自己的管理部分

每当我更新文档时,它与其他表的所有关系都会丢失

我在谷歌上搜索了一会儿,但找不到原因

你有没有经历过这样的事情?我能做什么

这是模式,但MySQL中不存在约束

Document:
  actAs: [Timestampable]
  columns:
    title: string(255)
    filename: string(255)
    owner_id: integer
Productar:
  actAs:
    Timestampable: ~
    I18n:
      fields: [title, tagline, intro, body]
  columns:
    title: string(255)
    tagline: clob
    intro: clob
    body: clob
    video: string(255)
    header_image: string(255)
    small_image: string(255)
  relations:
    Documents:
      class:        Document
      local:        productar_id
      foreign:      document_id
      type:         many
      refClass:     ProductarDocument
      onDelete:     SET NULL
ProductarDocument:
  actAs: [Timestampable]
  columns:
    productar_id:
      type: integer
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    document_id:
      type: integer
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
  relations:
    Productar:
      class:        Productar
      local:        productar_id
      foreign:      id
      onDelete:     SET NULL  # Also tried with CASCADE
    Document:
      class:        Document
      local:        document_id
      foreign:      id
      onDelete:     SET NULL  # Also tried with CASCADE

在phpmyadmin中,单击关系并查找onEdit操作

我发现了问题:

在模型中存在关系之前,最初与/document/web模块一起生成的表单类。后来,添加了关系,再次生成了表单和模型类,但没有生成表单的web模块或实际视图,因此表单类需要关系,但没有收到关系,并且在调用$form->save方法时,记录在没有关系的情况下被更新


我通过在DocumentForm类中取消设置productar_列表小部件和验证器来修复它。它不再被期待,也不再被保存。现在不更新关系。

谢谢你的建议。我已经添加了模式。很好的建议,但是没有。