Re: Deleting from $film->stars in Many to Many Example

[prev] [thread] [next] [Date index for 2004/11/22]

From: Peter Speltz
Subject: Re: Deleting from $film->stars in Many to Many Example
Date: 17:34 on 22 Nov 2004
--- Perrin Harkins <perrin@xxxx.xxx> wrote:

> On Mon, 2004-11-22 at 11:41, Peter Speltz wrote:
> > In the many to many example in Docs, what's best way to delete a star from
> a
> > film which deletes the Role) ?  Write a custom sub?
> 
> If you delete the roll, that means you want to delete all stars attached
> to it.  

BTW,
Only one actor(star) per role. Role is defined like this:
 Role->table('role');
 Role->columns(Primary => qw/film actor/);
 Role->has_a(film => 'Film');
 Role->has_a(actor => 'Actor');

>Class::DBI already does the cascading delete for you, so just
> delete the role and it takes care of the rest.
> 
> - Perrin

Right, I want to delete the role not the actor. With stars defined as in the
example
    Film->has_many(stars => [ Role => 'actor' ]);
then  when I say  
    film->stars[2]->delete
the actor get's deleted, not the role.  Not what i want. 

Whereas if stars were defined like this: 
    Film->has_many ( 'stars' => "Role" ); 
Then when i say 
    film->stars[2]->delete
the role gets deleted like i want it too.

This may just be a simple trade off. If you use the mapping capability for
has_many you get only the data you want from the map table but you don't get
simple deleting capabilities.  I was just curious what people do . 


=====
pjs


		
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - Get yours free! 
http://my.yahoo.com 
 

Re: Deleting from $film->stars in Many to Many Example
Peter Speltz 17:34 on 22 Nov 2004

Generated at 17:24 on 02 Dec 2004 by mariachi v0.52