【问题标题】:Symfony 1.4 Doctrine Relationship problemSymfony 1.4 教义关系问题
【发布时间】:2011-03-09 08:43:30
【问题描述】:

下面是我的 schema.yml

CmsFooter:
  actAs:
    I18n:
      fields: [title,description]
    Timestampable:
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    is_default:
      type: enum(1)
      values: [Y, N]
      default: N
      notnull: true
      autoincrement: false
    title:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    description:
      type: string()
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
LanguageMaster:
  actAs:
    Timestampable:
  columns:
    id:
      type: integer(11)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true  
    name:
      type: string(50)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    culture:
      type: string(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    is_active:
      type: enum(1)
      fixed: false
      unsigned: false
      values:
        - Y
        - N
      primary: false
      default: N
      notnull: true
      autoincrement: false
    is_default:
      type: enum(1)
      fixed: false
      unsigned: false
      values:
        - Y
        - N
      primary: false
      default: N
      notnull: true
      autoincrement: false
    file_name:
      type: string(50)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    CmsFooterTranslation:
      local: culture
      foreign: lang
      type: many
      onDelete: CASCADE
      onUpdate: CASCADE

我正在生成架构 -> 数据库。

当我运行这个架构时,它没有在数据库表中提供关系

表名:- cms_footer_translation 字段:- 语言

在关系中我需要它应该显示 language_master.culture ondelete cascade & onupdate cascade

有什么帮助吗??

【问题讨论】:

  • 提示:定义布尔值时(如您的情况下的is_default),只需使用:is_default: {type: boolean, notnull: true, default: 0}。它可以为您节省大量工作。 Detailed explanation here
  • 您能澄清一下您要完成哪些表之间的关系吗?我真的无法从你的问题中解脱出来。

标签: symfony1 doctrine symfony-1.4


【解决方案1】:

我定义的工作关系的一个例子是:

  relations:
    Testimony:
      class: Testimony
      local: testimony_id
      foreign: id
      foreignAlias: HomePage
      onDelete: cascade
      onUpdate: cascade
      foreignType: one
      owningSide: true
  indexes:
    fk_home_page_testimony1:
      fields: [testimony_id]

我会再读一遍documentation,然后把你和他们的比较一下。

【讨论】:

    猜你喜欢
    • 2011-08-31
    • 1970-01-01
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-22
    • 2013-01-01
    相关资源
    最近更新 更多