Symfony2 Doctrine association deletion problem
習慣沉默
習慣沉默 2017-05-16 16:44:12
0
1
373

Entity NotifyOrderCreate

/** * @ORM\Column(type="bigint",options={"unsigned"=true}) * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\OneToOne(targetEntity="Order", inversedBy="notifyCreate",cascade={"persist"}) * @ORM\JoinColumn(name="order_id", referencedColumnName="id",onDelete="CASCADE") **/ private $order;

Entity Order

/** * @ORM\Column(type="bigint",options={"unsigned"=true}) * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\OneToOne(targetEntity="NotifyOrderCreate", mappedBy="order") **/ private $notifyCreate;

Find out that NotifyOrderCreate will also delete the order when executing remove. Please tell me how to break it.

習慣沉默
習慣沉默

reply all (1)
phpcn_u1582

I don’t understand how to write comments. Given below is the yml code:

oneToOne: order: targetEntity: SomeEntity joinColumn: name: some_id referencedColumnName: pk_id nullable: true onDelete: SET NULL

This way of writing will set the field to NULL when deleting.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!