using onDelete with Doctrine 2

后端 未结 2 1728
萌比男神i
萌比男神i 2021-02-09 17:45

I can\'t get the onDelete to work in Doctrine2 (with YAML Mapping).

I tried this relation in my Product class:

oneToOne:
    category:
              


        
相关标签:
2条回答
  • 2021-02-09 18:03

    OK, got it! I had to use onDelete inside joinColumn:

    oneToOne:
        category:
            targetEntity: Category
            joinColumn:
                onDelete: CASCADE
    
    0 讨论(0)
  • 2021-02-09 18:05

    This is the way to use onDelete in joinTable:

    manyToMany:
        parameters:
            targetEntity: Fox\LandingBundle\Entity\Parameter
            cascade: ["persist","remove"]
            joinTable:
                name: subscriberBox_parameter
                joinColumns:
                    subscriberBox_id:
                        referencedColumnName: id
                inverseJoinColumns:
                    parameter_id:
                        referencedColumnName: id
                        onDelete: CASCADE
    
    0 讨论(0)
提交回复
热议问题