[Dbix-class] deleting many-to-many relationship entries in one query

Leandro Hermida softdev at leandrohermida.com
Wed Jan 19 15:05:17 GMT 2011


Hi everyone,

Couldn't find the answer to this simple question.... maybe not looking in
the right place

I have a standard many-to-many setup:

person ------< person2address >------- address

And have defined it in the standard documented way with DBIC.  How do I in
my code, where I have an instance of the $person object and using
relationships, delete all this person's person2address entries in one query
without touching any addresses?

Not sure if I am using the right jargon when I said "using relationships"
like I saw in the manual, what I mean is that I feel this style:

$person->cars->delete();

is cleaner and more readable than this:

$schema->resultset('Car')->search({
    person =3D> $person,
})->delete();

How would I do it with a many-to-many just to delete the relationship
entries?

best,
Leandro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20110119/32a=
d5cc6/attachment.htm


More information about the DBIx-Class mailing list