Hi again,
Not sure if this is the way, did:
$person->delete_related('person2address');
which works, where 'person2address' relationship in
MySchema::Result::Person:
__PACKAGE__->has_many('person2address' =>
'MySchema::Result::Person2Address', 'person_id');
__PACKAGE__->many_to_many('addresses' => 'person2address', 'address');
Is this the only way to do it using relationships? Seems like this way:
$person->person2address->delete();
Gives
Can't locate object method "person2address" via package
"MySchema::Result::Person"
-L
On Wed, Jan 19, 2011 at 4:05 PM, Leandro Hermida <[email protected]
> wrote:
> 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 => $person,
> })->delete();
>
> How would I do it with a many-to-many just to delete the relationship
> entries?
>
> best,
> Leandro
>
>
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]