[CDBI] Many to many help

[prev] [thread] [next] [Date index for 2005/08/01]

From: Mike McKay
Subject: [CDBI] Many to many help
Date: 08:38 on 01 Aug 2005
I need some help with a Many to Many situation. I have two tables, 
passenger and route, which are in a many to many relationship via a 
PassengerRouteJoin table. I followed the perldoc for Class::DBI to 
create the many to many relationship using inflation. But it doesn't 
work. Here is basically what I am doing:

PassengerRouteJoin->has_a(passenger => "Passenger");
PassengerRouteJoin->has_a(route => "Route");

Route->has_many(passengers => [ "PassengerRouteJoin" => 'passenger' ]);
Passenger->has_many(routes => [ "PassengerRouteJoin" => 'route' ]);

So then I try and do this:

my $p = Passenger->create({surname => "Blah", first_name => "Foo"}); 

my $r = Route->create({departure_point => "Lilongwe", destination => 
"Likoma"});

$p->add_to_routes({route => $r});

Can't deflate route: 8 is not a Route at 
/usr/local/share/perl/5.8.4/Class/DBI/Relationship/HasA.pm line 87


I have also tried this:

my $p = Passenger->create({surname => "Blah", first_name => "Foo"}); 

$p->add_to_routes({departure_point => "Lilongwe", destination => "Likoma"});

destination is not a column of PassengerRouteJoin at 
/usr/local/share/perl/5.8.4/Class/DBI/Relationship/HasMany.pm line 89



Any suggestions?

Mike



_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

[CDBI] Many to many help
Mike McKay 08:38 on 01 Aug 2005

Re: [CDBI] Many to many help
William Ross 09:16 on 01 Aug 2005

Re: [CDBI] Many to many help
William Ross 11:03 on 01 Aug 2005

Re: [CDBI] Many to many help
Bill Moseley 16:42 on 01 Aug 2005

Generated at 21:01 on 07 Aug 2005 by mariachi v0.52