Symfony Doctrine Schema分段错误

时间:2010-02-26 11:18:36

标签: symfony1 doctrine segmentation-fault

我正在设置我的第一个symfony项目,并且我遇到了架构问题。我不确定我是否会采用正确的方式。

我的两节课出了问题。我有客户,可以有很多联系人,其中一个联系人需要被选为发票联系人。这是我的架构:

NativeClient:
  actAs: { Timestampable: ~ }
  columns:
    name:                { type: string(255), notnull: true }
    address:             { type: string(255) }
    postcode:            { type: string(9) }
    tel:                 { type: string(50) }
    fax:                 { type: string(50) }
    website:             { type: string(255) }
    client_status_id:    { type: integer, notnull: true, default: 0 }
    priority:            { type: boolean, notnull: true, default: 0 }
    invoice_contact_id:  { type: integer }
    invoice_method_id:   { type: integer }
  relations:
    NativeContact:       { local: invoice_contact_id, foreign: id, foreignAlias: NativeInvoiceContacts }
    NativeClientStatus:  { local: client_status_id, foreign: id, foreignAlias: NativeContacts }
    NativeInvoiceMethod: { local: invoice_method_id, foreign: id, foreignAlias: NativeClientStatuses }


NativeContact:
  actAs: { Timestampable: ~ }
  columns:
    client_id:          { type: integer, notnull: true }
    name:               { type: string(255), notnull: true }
    position:           { type: string(255) }
    tel:                { type: string(50), notnull: true }
    mobile:             { type: string(50) }
    email:              { type: string(255) }
  relations:
    NativeClient:       { onDelete: CASCADE, local: client_id, foreign: id, foreignAlias: NativeClients } 

NativeClientStatus:
  actAs: { Timestampable: ~ }
  columns:
    name:               { type: string(255), notnull: true }

NativeInvoiceMethod:
  actAs: { Timestampable: ~ }
  columns:
    name:               { type: string(255), notnull: true }

如果我删除以下行(和相关的灯具),它会起作用,否则我会遇到分段错误。

NativeContact:       { local: invoice_contact_id, foreign: id, foreignAlias: NativeInvoiceContacts }

它可能会进入循环吗?试图一遍又一遍地引用客户和联系人?任何帮助将不胜感激!谢谢!

的Darren

2 个答案:

答案 0 :(得分:2)

我知道这个老问题,但这是一个后续解决方案。有时,Doctrine会因为看似没有任何理由而抛出这个错误。我确定有一个潜在的原因,但我们没有时间调试整个Doctrine源。

尝试指定--env = [你的环境],它可能只是工作 - 对我来说。

答案 1 :(得分:0)

达伦,看起来你在使用冲突标准的同时定义了两端的关系......

NativeContact:       { local: invoice_contact_id, foreign: id, foreignAlias: NativeInvoiceContacts }

...关系在NativeContact中的“invoice_contact_id”和未声明的“id”PK之间。

 NativeClient:       { onDelete: CASCADE, local: client_id, foreign: id, foreignAlias: NativeClients } 

...相同的关系是在NativeClient中的“client_id”和未声明的“id”PK之间。

我个人只在一端定义这些,然后让Doctrine处理剩下的事情,但这取决于你在这里想要实现的目标。如果一个客户端有多个联系人,你可以删除第二个声明并仅在clients表中定义关系,并添加“type:many,foreignType:one”来表明它是一对多的关系。