[CDBI] relationships with mcpk's

Perrin Harkins perrin at elem.com
Wed Mar 15 02:15:44 GMT 2006


Mark Hedges wrote:
> How do I define relationships from one class to another that has
> multiple-column primary keys in its table?

It isn't directly supported, but there are various ways to do it.  I'll 
show you what I usually do:

>         warn join(q{,}, My::Foo->primary_columns),"\n";
>         # warns "bar,biz".
>         
>         # I feel like I should be able to do this:
>     
>         My::Baz->has_a( foo => 'My::Foo' );

package Bar::Baz;

sub foo {
     my $self = shift;
     return My::Foo->retrieve(bar => $self->bar,
                              biz => $self->biz);
}

- Perrin




More information about the ClassDBI mailing list