简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM