has_a and the accessor name

[prev] [thread] [next] [Date index for 2005/03/26]

From: Josef Chladek
Subject: has_a and the accessor name
Date: 07:38 on 26 Mar 2005
maybe this is purely trivial, but i can't find a solution:

i have a ont-to-one relationship between two tables:

package Newsletter::Main;
use base 'Newsletter::DBI';

__PACKAGE__->table( "Newsletter" );
__PACKAGE__->columns(Primary => qw /id/);
__PACKAGE__->columns(Essential => qw /email/ );
__PACKAGE__->columns(Others => qw /no_mails modified md5/ );
__PACKAGE__->has_a( "id", "Newsletter::Attributes");

package Newsletter::Attributes;
use base 'Newsletter::DBI';

__PACKAGE__->table( "Newsletter_Attributes" );
__PACKAGE__->columns(Primary => qw /newsletter/ );
__PACKAGE__->columns(Essential => qw /vorname nachname anrede/ );
__PACKAGE__->has_a( "newsletter", "Newsletter::Main");

if i create the main object via

$cid = Newsletter::Main->create(\%data);

i then prepare the %data_attributes for the Attributes,

$data_attributes{newsletter} = $cid;
$aid = Newsletter::Attributes->create(\%data_attributes);

everything works fine. but my program is more generalized, so i would 
need something to return me the accessor in Attributes, so i would get 
'newsletter' in my example.

it should look like
my $foreign_accessor = 
Newsletter::Attributes->return_me_the_accessor_of_has_a # which would 
return 'newsletter'
$data_attributes{$foreign_accessor} = $cid;

do i have to write a method on my own or have i overlooked something?

thanks
josef

has_a and the accessor name
Josef Chladek 07:38 on 26 Mar 2005

Re: has_a and the accessor name
William Ross 08:46 on 26 Mar 2005

Re: has_a and the accessor name
Josef Chladek 19:18 on 27 Mar 2005

Re: has_a and the accessor name
.--- .- -- . ... 18:02 on 26 Mar 2005

Re: has_a and the accessor name
Peter Speltz 06:23 on 28 Mar 2005

Re: has_a and the accessor name
Josef Chladek 07:50 on 28 Mar 2005

Re: has_a and the accessor name
Peter Speltz 17:59 on 28 Mar 2005

Generated at 14:42 on 11 Apr 2005 by mariachi v0.52