http://stackoverflow.com/questions/1488171/in-symfony-doctrines-schema-yml-where-should-i-put-ondelete-cascade-for-a-many
http://groups.google.com/group/doctrine-user/browse_thread/thread/2f924ee3b8cd2689?pli=1
http://trac.doctrine-project.org/ticket/1123
The common theme is if you want an onDelete on a many-to-many relationship then you have to put it on the reference table. But not a single example anywhere. So, let's start with the "friends" nest example in the manual.
Here is what does not work (no error, simply leaves the records behind in FriendReference)
User:
# ...
relations:
# ...
Friends:
class: User
local: user1
foreign: user2
refClass: FriendReference
equal: true
onDelete: CASCADE
FriendReference:
columns:
user1:
type: integer
primary: true
user2:
type: integer
primary: true
This one won't even compile (well, I didn't think it would):
User:
# ...
relations:
# ...
Friends:
class: User
local: user1
foreign: user2
refClass: FriendReference
equal: true
FriendReference:
columns:
user1:
type: integer
primary: true
user2:
type: integer
primary: true
relations:
onDelete: CASCADESo, how do we change it so it will work? I'll update this if and when I work it out; if you know please let me know.
No comments:
Post a Comment