many2many
[prev]
[thread]
[next]
[Date index for 2005/04/11]
This is a multi-part message in MIME format.
------=_NextPart_000_00E2_01C53E94.89E93090
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I am trying to implement a many to many relationship with
#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
{package Sites;
Sites->has_many (siteenzymes =3D> ['EnzymeSites' =3D> 'enzid']);
#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
{package Enzymes;
Enzymes->has_many (enzsites =3D> ['EnzymeSites' =3D> 'siteid']);
#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
{package EnzymeSites;
EnzymeSites->columns(Primary =3D> qw/ siteid enzid /);
EnzymeSites->has_a (enzid =3D> 'Enzymes');
EnzymeSites->has_a (siteid =3D> 'Sites');
but when I execute:
my $enzyme =3D Enzymes->retrieve(enzyme =3D> 'TstI');
my @sites =3D $enzyme->enzsites;
I get the error:
enzymes is not a column of EnzymeSites
If I add
__PACKAGE__->has_many(allsites =3D> 'EnzymeSites', 'enzid');
sub actors {=20
my $self =3D shift;
return map $_->siteid->site, $self->allsites;=20
}
to the Enzymes package and execute
my @sites =3D $enzyme->actors;
print "$enzyme sites\n" . join ("\n", @sites), "";
=20
it works fine.
What is causing the error?
Thanks,
Barry
------=_NextPart_000_00E2_01C53E94.89E93090
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2604" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I am trying to implement a many to many =
relationship with</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>{package Sites;<BR> =20
Sites->has_many (siteenzymes =3D> ['EnzymeSites' =3D> =
'enzid']);<BR>
<DIV><FONT face=3D"Courier New"=20
size=3D2>#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>{package Enzymes;<BR> =20
Enzymes->has_many (enzsites =3D> ['EnzymeSites' =3D> =
'siteid']);<BR>
<DIV><FONT face=3D"Courier New"=20
size=3D2>#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>{package=20
EnzymeSites;<BR> EnzymeSites->columns(Primary =3D> qw/ =
siteid enzid=20
/);<BR> EnzymeSites->has_a (enzid =3D> =
'Enzymes');<BR> =20
EnzymeSites->has_a (siteid =3D> 'Sites');</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>but when I execute:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> my $enzyme =3D=20
Enzymes->retrieve(enzyme =3D> 'TstI');<BR> my @sites =
=3D=20
$enzyme->enzsites;<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I get the error:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> enzymes is =
not a column=20
of EnzymeSites</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>If I add</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2> =
__PACKAGE__->has_many(allsites=20
=3D> 'EnzymeSites', 'enzid');<BR> sub actors=20
{ <BR> my $self =3D shift;<BR> =
=20
return map $_->siteid->site,=20
$self->allsites; <BR> }<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>to the Enzymes package and=20
execute</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Courier New"> my =
@sites =3D=20
$enzyme->actors;<BR> print "$enzyme sites\n" . join ("\n", =
@sites),=20
"";<BR></FONT></DIV></FONT>
<DIV><FONT face=3DArial size=3D2> <BR>it works fine.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV></DIV>
<DIV><FONT face=3DArial size=3D2>What is causing the error?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Barry</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV></BODY></HTML>
------=_NextPart_000_00E2_01C53E94.89E93090--
|
many2many
Barry Dancis 16:46 on 11 Apr 2005
|