has_a and the accessor name
[prev]
[thread]
[next]
[Date index for 2005/03/26]
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
|