Symfony Doctrine Schema Segmentation Fault

I'm setting up my first symfony project, and am having trouble with the schema. I'm not sure if I'm going about it the right way.

I'm having a problem with two of my classes. I have Clients, which can have many Contacts, one of the contacts needs to be selected as the invoice contact. This is my schema:

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 }

If i remove the following line (and associated fixtures) it works, otherwise I get a segmentation fault.

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

Could it be getting in a loop? Trying to reference the Client and the Contact over and over? Any help would be greatly appreciated! Thanks!

Darren

Answers


Darren, it seems like you're defining the relationship at both ends while using conflicting criteria...

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

...relationship is between "invoice_contact_id" and undeclared "id" PK in NativeContact.

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

... same relationship is between "client_id" and undeclared "id" PK in NativeClient.

I personally only define these in one end and let Doctrine handle the rest, but it depends on what you're trying to achieve here. If ONE client HAS MANY contacts, you could drop the second declaration and define the relationship in the clients table only and add "type: many, foreignType: one" to state that it's a one-to-many relationship.


Old question I know, but heres a follow up solution. Sometimes Doctrine will throw this error for seemingly no reason whatsoever. Im sure there is an underlying reason, but we dont all have time to debug the entire Doctrine source.

Try specifying --env=[your env], and it may just work - has for me.


Need Your Help

Uncaught SyntaxError Multiple Appends

jquery append

I have having problems appending more then one object to a UL list. The error shows on line 68 which is separately commented out

R Recession Dates Conversion

r quantmod performanceanalytics

I am downloading recession band data into R via quantmod. Now this comes as a binary information (in xts format) looking like this (just the first recession period shown)