On 17/06/2009 13:12, Ian Wells wrote:
2009/6/17 Jason Galea<[email protected]>:
Hi Dave,

package DB::Film;

...

# has many actors
__PACKAGE__->has_many('film_actor_maps' =>  'DB::FilmActorMap', 'product');
__PACKAGE__->many_to_many('actors' =>  'film_actor_maps', 'actor');

__PACKAGE__->belongs_to('director' =>  'DB::Director');


I'd do it the other way around:

package DB::Actor;
...
# Has many films
__PACKAGE__->has_many('actor_film_maps' =>  'DB::FilmActorMap', 'product');
__PACKAGE__->many_to_many('films' =>  'actor_film_maps', 'film');

my $rs = $actor->films->search(director =>  39);

Thanks. That's exactly what I was looking for. I'd have got there myself too - given another eight or ten hours of trying :-/

Cheers,

Dave...

_______________________________________________
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]

Reply via email to