【问题标题】:Use of "Container" as model name in Symfony在 Symfony 中使用“Container”作为模型名称
【发布时间】:2011-09-12 13:45:21
【问题描述】:

我在 Symfony 应用程序中有一个名为 Container 的实体,我已将其包含在 schema.yml 文件中:

Container:
  columns:
    id:    { type: integer, primary: true, autoincrement: true }
    name:  { type: string(127), notnull: true }

Strain:
  columns:
    id: { type: integer, primary: true, autoincrement: true }
    ...
    container_id: { type: integer }
    ...
  relations:
    Container:  { foreignAlias: Strains }

然后我使用symfony doctrine:build --all-classes 任务重新生成了模型、表单和过滤器。

现在当我尝试使用 $strain->getContainer() 时,例如在showSuccess 操作中,它根本不返回任何对象。我仔细检查了container_id 是否引用了container 表中的记录。

此外,当我尝试编辑Strain 对象并取消与Container 的关系时,表单已正确保存,但container_id 列保留旧值。

你知道Container 是保留字还是 Symfony 或 Doctrine 中的保留字?会发生什么?

谢谢!

【问题讨论】:

    标签: php symfony1 model doctrine reserved-words


    【解决方案1】:

    不,它不是保留字。 (事实上​​,我的项目中有一个具有Container 关系的模型)。

    您是否尝试过将Container 上的local 属性设置为与container_id 的关系?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-27
      相关资源
      最近更新 更多