Doctrine2 - 如何设置oneToOne实体而不是id

时间:2013-05-29 20:02:32

标签: php symfony orm doctrine

这是映射信息的一部分:

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

如何与ms_id建立连接而不是id

1 个答案:

答案 0 :(得分:1)

您可以使用 referencedColumnName 指定连接列参数, 请参阅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