[prev] [thread] [next] [Date index for 2004/06/07]
After reading the docs and scanning this lists archives, I am left wondering how to accomplish the following. Database schema: (unessential columns omitted for brevity) create table Things ( ThingId integer unsigned not NULL auto_increment, node varchar(80), ... primary key(ThingId) ); create table Links ( LinkId integer unsigned not NULL auto_increment, linklable varchar(80), srcThingId integer unsigned, dstThingId integer unsigned, primary key (LinkId) ); The idea for the database is to track the relationship between a set of "Things." I have the following set up in a package: package XYZ::DB; use base qw(Class::DBI); use warnings; XYZ::DBI->connection(connection_details_omitted); package XYZ::Things; use base qw(XYZ::DB); XYZ::Things->table('Things'); XYZ::Things->columns(All=>qw(ThingId node)); XYZ::Things->has_many(links => 'XYZ::Links'); package XYZ::Links; use base qw(XYZ::DB); XYZ::Links->table('Links'); XYZ::Links->columns(All=>qw(LinkId linklable srcThingId dstThingId)); XYZ::Links->has_a(srcThingId => 'XYZ::Things'); XYZ::Links->has_a(dstThingId => 'XYZ::Things'); Now in my program I am trying to delete a thing using the following: my $obj = XYZ::Things->retrieve("7"); # get ThingId = 7, which exists in DB $obj->delete; When that snippet runs, I get the following error: things is not a column of XYZ::Links at /usr/local/libdata/perl5/site_perl/Class/DBI/Relationship/HasMany.pm line 61 Can anyone shed some light on what I'm doing wrong? Any help will be appreciated. Thanks in advance, Todd
many to many help
|
Generated at 11:34 on 01 Dec 2004 by mariachi v0.52