in reply to Extension of DBIC "model" class

Have a look at DBIx::Class::Manual::Joining

Your problem is easily solved by joining these tables together.

DBIC has ample methods for it.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: Extension of DBIC "model" class
by roman (Monk) on May 09, 2008 at 19:56 UTC

    No, this is different case, all examples in joining manuals describe how to access related but independent objects - there is always one object one row.

    What I am looking for is how to implement the inheritance with additional attributes in DBIC.

    An unsophisticated example:

    -- I have an animal table describing species create table myschema.animal ( species varchar2(64) primary key, region varchar2(64) ); -- and some tables extending the animal create table myschema.animal_mammal ( species varchar2(64), -- foreign key max_height number, quadrupedal number(1) default 1 -- 0 or 1 ); create table myschema.animal_bird ( species varchar2(64), -- foreign key max_wingspan number, number_of_eggs number );

    I would like to create the DBIC classes for mammal and bird so I can work with them as single objects.

    my $dog = $schema->resultset('Mammal')->find('Canis familiaris'); warn $dog->region, ' ', $dog->max_height; my $chimp = $schema->resultset('Mammal')->create({ 'species' => 'Pan troglodytes', 'region' => 'Africa', 'quadrupedal' => 0, });