Here is a module that I am working on that is a derivative of Class::DBI:

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) );
The relationship to pay attention to here is this one:
TrialWorkers::Person->has_many(daysignup=>'TrialWorkers::DaySignup');
In the module TrialWorkers::DaySignup I have the following:
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

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} } ); }
I see the following in the apache error log:
[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?


In reply to Class::DBI has_many relationships. by blue_cowdawg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.