blue_cowdawg has asked for the wisdom of the Perl Monks concerning the following question:
Here is a module that I am working on that is a derivative of Class::DBI:
The relationship to pay attention to here is this one:package TrialWorkers::Person; use base 'TrialWorkers::DBI'; TrialWorkers::Person->table('people'); TrialWorkers::Person->columns( All=>qw[ people_id user_id first_name last_name comments ] ); TrialWorkers::Person->has_many(priveleges=>'TrialWorkers::Priveleges') +; TrialWorkers::Person->has_many( password_notification=>'TrialWorkers::PasswordNotifica +tion'); TrialWorkers::Person->has_many(jobsignup=>'TrialWorkers::JobSignup'); TrialWorkers::Person->has_many(daysignup=>'TrialWorkers::DaySignup'); TrialWorkers::Person->has_many(dogs=>'TrialWorkers::Dog'); TrialWorkers::Person->has_a(user_id=>'TrialWorkers::User'); use Class::DBI::DATA::Schema; 1; __DATA__ drop table if exists people; create table people ( people_id integer unsigned not null auto_increment primary key, user_id integer unsigned not null, first_name varchar(40) not null, last_name varchar(40) not null, comments varchar(128), unique index (people_id,user_id) ); drop table if exists priveleges; create table priveleges ( priv_id integer not null auto_increment primary key, people_id integer not null, is_admin enum ('N','Y') not null default 'N', can_sched enum ('N','Y') not null default 'N', unique index (priv_id,people_id) ); drop table if exists password_notification; create table password_notification ( pn_id integer not null auto_increment primary key, people_id integer not null, notified enum ('N','Y') not null default 'N', bounced enum('N','Y') not null default 'N', whenNotified date not null default '2004-08-01', unique index (pn_id,people_id,whenNotified) );
In the module TrialWorkers::DaySignup I have the following:TrialWorkers::Person->has_many(daysignup=>'TrialWorkers::DaySignup');
package TrialWorkers::DaySignup; use base 'TrialWorkers::DBI'; TrialWorkers::DaySignup->table('day_signup'); TrialWorkers::DaySignup->columns( All => qw/ day_signup_id people_id day_working / ); TrialWorkers::DaySignup->has_a(people_id=>'TrialWorkers::People'); 1; __DATA__ drop table if exists day_signup; create table day_signup( day_signup_id integer unsigned not null auto_increment primary key, people_id integer not null, day_working integer not null, unique index (people_id,day_working) );
Now I would think based on the doco for Class::DBI it should work correctly. Indeed a similar relationship between two other modules does indeed work correctly (TrialWorkers::User has many TrialWorkers::Person). When I run
I see the following in the apache error log:my $person = $uid->add_to_people( $create_data ); my @days=$cgi->param('work_on_rq'); #when will they work? carp (Dumper($person)); #yep... it is the correct type foreach my $day(@days) { $person->add_to_daysignup( { day_working => $day_map{$day} } ); }
[Sat Aug 21 22:36:41 2004] [error] [client 127.0.0.1] person is not a +column of TrialWorkers::DaySignup at /usr/lib/perl5/site_perl/5.8.5/C +lass/DBI/Relationship/HasMany.pm line 89, referer: http://localhost/V +olunteer_Entry.html
what in the world am I overlooking?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Class::DBI has_many relationships.
by castaway (Parson) on Aug 22, 2004 at 07:43 UTC | |
by blue_cowdawg (Monsignor) on Aug 23, 2004 at 15:07 UTC | |
|
Re: Class::DBI has_many relationships.
by Juerd (Abbot) on Aug 22, 2004 at 10:27 UTC |