Re: Multi column foreign keys

[prev] [thread] [next] [Date index for 2004/09/03]

From: Perrin Harkins
Subject: Re: Multi column foreign keys
Date: 15:44 on 03 Sep 2004
Y00R0B0T wrote:

> Hello... I'm wondering if anyone on this list had to deal with
> multi-column foreign keys and if so, how'd it go?  Did you create your
> own relationship type (ie Class::DBI::Relationship) or did you find a
> work around within standard CDBI?

I've done this quite a bit with no problems.  I just made my own simple 
method:

sub foreign_obj {
     my $self = shift;
     my $foreign_obj = Foreign::Class->retrieve(
                                                key1 => $self->key1(),
                                                key2 => $self->key2(),
                                               );
     return $foreign_obj;
}

It doesn't do everything that has_a normally does (e.g. this is just a 
getter, not a get/set) but you can make it do more if you need to. 
Support in has_a would be nice at some point.

- Perrin

Multi column foreign keys
Y00R0B0T 15:19 on 02 Sep 2004

Re: Multi column foreign keys
Yuval Kogman 09:20 on 03 Sep 2004

Re: Multi column foreign keys
Perrin Harkins 15:44 on 03 Sep 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52