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::PasswordNotification');
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)
);
####
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)
);
####
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/Class/DBI/Relationship/HasMany.pm line 89, referer: http://localhost/Volunteer_Entry.html