[CDBI] has_a relationship with non-primary column?

Perrin Harkins perrin at elem.com
Fri Sep 7 04:59:45 BST 2007

On 9/6/07, Praveen Hombaiah <phombaiah at gmail.com> wrote:
> Isn't the first argument the column(of this class ie department ) that
> stores the value of the PK of the "other" class?  Is it possible to store
> the non-pk value of the "other" class in the column and indicate that in the
> has_a declaration somehow?

Oh, now I see what you're asking.  You can't do that with has_a, but
making your own accessor is pretty simple:

sub department_object {
    my $self = shift;
    return Department->desired_column($self->department);

If you want this method to be called department and the accessor for
the department column to be called something different, you can find
recipes for changing accessor names on the wiki.

- Perrin

More information about the ClassDBI mailing list