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: 22:35 on 22 Nov 2004
--- Perrin Harkins <perrin@xxxx.xxx> wrote:

> > 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.
> 
> But then you don't get Actors back when you call Film->stars().
> 

Right. That's what I want. My situation is a better example: User, Privelage,
and a Usr_Privelage mapping table and I'm adding and deleting Usr_Privelages
with checkbox interface.

> You can always delete Roles directly:
> 
> Role->delete( actor => $actor, film => $film );
> 

That's what i'm after. Thanks so much. For some reason I had it in my mind
delete was strictly and object method. Don't know where i got that idea. 

> Or you could use the second approach (without mapping to Actors) and
> code a separate method for getting the Actors efficiently without the
> extra database calls.  It kind of depends on your usage pattern and what
> feels more natural in your app. 
> 

Yep. Thanks again. 
 


=====
pjs


		
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 

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

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