nkt
nkt

Reputation: 75

Doctrine2 - How set oneToOne entity not by id

That is part of mapping info:

id:
    type: integer
    id: true
    generator:
        strategy: AUTO
ms_id:
    type: string
    unique: true
oneToOne:
    parent:
        targetEntity: Category
        nullable: true

How do I establish a connection with ms_id instead of the id

Upvotes: 0

Views: 91

Answers (1)

Nisam
Nisam

Reputation: 2285

You can specify the join column parameters with referencedColumnName, see the association mapping document

id:
    type: integer
    id: true
    generator:
        strategy: AUTO
ms_id:
    type: string
    unique: true
oneToOne:
    parent:
        targetEntity: Category
        joinColumn:
          name: category_id
          referencedColumnName: ms_id
        nullable: true

Upvotes: 1

Related Questions