symfony - Removing related entity Symfony2 -
i have related entities. many many relation , annotation exists on 1 entity:
/** * @orm\manytomany(targetentity="event") * @orm\jointable(name="viewed_events", * joincolumns={@orm\joincolumn(name="user_id", referencedcolumnname="id")}, * inversejoincolumns={@orm\joincolumn(name="event_id", referencedcolumnname="id")} * ) **/ protected $viewedevents;
the problem when try delete event entity integrity constraint violation: 1451 cannot delete or update parent row: foreign key constraint fails
error. how solve this? tried adding orphanremoval=true
that: @orm\manytomany(targetentity="event", orphanremoval=true)
, tried adding cascade="delete"
, cascade="all"
instead no success.
ondelete="cascade"
on yours joincolumn.
Comments
Post a Comment