horshack has asked for the wisdom of the Perl Monks concerning the following question:
Can't locate object method "kontakte" via package "Customercare::Kundenkontakte" at cc.pl line x.
What I really want is find a list of customer which had contact with my company. Like this:
01. Libary X
talk
postcard
02. Library Y
postcard
But I thought it's better to retrieve that list by asking
for the contacts first.
Can you help me?
Thanks,
Horshack
#!/usr/bin/perl use strict; # Buechereien -> german for Libraries # Kundenkontakte -> german for customer-contacts # use Customercare::Buechereien; use Customercare::Kundenkontakte; my @kk = Customercare::Kundenkontakte->retrieve_all; my $i = 0; foreach (@kk) { last if $i++ > 10; printf "%02d. %s\n", $i, $_->customer->plzort; # This is where the problem occurs: foreach ( $_->kontakte ) { printf " %s\n", $_->aktion_kurz; } } package Customercare::Buechereien; use strict; use base 'Customercare::DBI'; __PACKAGE__->set_up_table("buechereien"); __PACKAGE__->has_many( # This will create a new Method named "kontakte" "kontakte", 'Customercare::Kundenkontakte' => "customer"); 1; package Customercare::Kundenkontakte; use strict; use base 'Customercare::DBI'; __PACKAGE__->set_up_table("kundenkontakte"); __PACKAGE__->has_a( customer => 'Customercare::Buechereien' ); 1; These are the tabledefinitions: CREATE TABLE buechereien ( customer varchar(50) NOT NULL default '', anschrift1 varchar(100) default NULL, plzort varchar(100) default NULL, tel varchar(50) default NULL, PRIMARY KEY (customer) ) TYPE=MyISAM; CREATE TABLE kundenkontakte ( lfdnr int(11) NOT NULL auto_increment, customer varchar(50) NOT NULL default '', aktion_kurz varchar(50) NOT NULL default '', PRIMARY KEY (lfdnr) ) TYPE=MyISAM;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: has_many in Class:DBI
by saintmike (Vicar) on Feb 16, 2004 at 00:18 UTC | |
|
Re: has_many in Class:DBI
by cees (Curate) on Feb 16, 2004 at 02:46 UTC | |
by horshack (Acolyte) on Feb 16, 2004 at 07:28 UTC |