Symfony1 Symfony模式分割错误
我正在设置我的第一个symfony项目,但在模式方面遇到了问题。我不确定我是否走对了路 我有两门课有问题。我有客户,可以有许多联系人,其中一个联系人需要被选为发票联系人。这是我的模式:Symfony1 Symfony模式分割错误,symfony1,doctrine,segmentation-fault,Symfony1,Doctrine,Segmentation Fault,我正在设置我的第一个symfony项目,但在模式方面遇到了问题。我不确定我是否走对了路 我有两门课有问题。我有客户,可以有许多联系人,其中一个联系人需要被选为发票联系人。这是我的模式: NativeClient: actAs: { Timestampable: ~ } columns: name: { type: string(255), notnull: true } address: { type: string(
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 }
这会不会是一个循环?试图一次又一次地引用客户和联系人?任何帮助都将不胜感激!谢谢
DarrenDarren,似乎您在定义两端的关系,同时使用了冲突的标准
NativeContact: { local: invoice_contact_id, foreign: id, foreignAlias: NativeInvoiceContacts }
…关系是NativeContact中“发票\联系人\ id”和未声明的“id”主键之间的关系
NativeClient: { onDelete: CASCADE, local: client_id, foreign: id, foreignAlias: NativeClients }
。。。NativeClient中“client_id”和未声明的“id”主键之间存在相同的关系
我个人只在一端定义了这些,其余的由条令来处理,但这取决于你在这里试图实现什么。如果一个客户端有多个联系人,您可以删除第二个声明,只在clients表中定义关系,并添加“type:MANY,foreignType:ONE”以说明这是一对多关系。我知道的老问题,但这里有一个后续解决方案。有时教义会无缘无故地抛出这个错误。我确信有一个潜在的原因,但是我们没有时间去调试整个条令源代码
试着指定--env=[your env],它可能对我来说就是有效的-has。好的,所以看起来我用了错误的方法。是否存在以下结构:-有许多客户端;-每个客户端可以有多个联系人;-其中一个联系人可以是发票联系人;我是否需要使用一个桥接类,比如ClientInvoiceContact,它只有客户机和联系人的ID?当客户端可以在其中存储联系人ID时,这听起来是多余的。我知道它可以被看作是一个循环引用,这可能是代码遇到困难的地方,但本质上我想将其中一个联系人设置为“主要”。非常非常好的解决方法。同意调试。我原以为ORM应该是更少的工作,但这根本不是教条的情况。不过,你确实少了很多被遗忘的地方。谢谢你,眩晕。我已经使用Symfony 1.4+原则1.2 5年了,由于某种原因,直到今天才发现这个错误。SEGFULT,除非我指定了环境。