Need help handling multiple related entities and removal symfony2
Let say you have an entity A that is related to B, C, and D.
When I try to delete B it will give me a parent exception because A is
still alive which is normal but I can't just delete A because C and D also
depends on it. My question is what is the best way in Symfony2 to handle
this kinds of errors because my database contains a lot of relationship
like this and I can't just go around all the entities checking if they
have childs or things like that, I know there must be a standard or
something but in their website they don't have any documentation that can
help me with this.
[Site] -Id -Name -Etc [Person] -id -site(reference)
[Cat] -id -site(reference)
[Car] -id Site(reference) Person(reference) Cat(reference)
[Wheel] -id -car(Reference)
[Seat] -id -car
In this example I would like to delete one of the Car entries... I
wouldn't know which entity is causing the problem in an exception, if it's
a child then there's no problem I could use cascade, but Idk which parent
is causing the problem in the exception, what I don't want is to keep
track of all the entities that are parents and search in the database blab
la bla if a flush causes an exception.. I want to know if there's a way
that Symfony2 could tell me something simple like (you can't delete car
because it depends on site, person and cat). Otherwise I would have to
search inside the exception to see what the cause of the error was.
Thanks in advance.
Benjamin.
No comments:
Post a Comment