in reply to Re: Class::DBI and a self-referencing many-to-many
in thread Class::DBI and a self-referencing many-to-many
my $parent1 = Person->create({ name => 'P1' }); my $parent2 = Person->create({ name => 'P2' }); my $child = Person->create({ name => 'C1' }); # This seems like a cumbersome way to set up the relationships $child->add_to_parents({ parent => $parent1 }); $child->add_to_parents({ parent => $parent2 }); # Or, alternatively # $parent1->add_to_children({ child => $child }); # $parent2->add_to_children({ child => $child });
Is there any way to sucessfully set those relationships when I'm constructing the objects?
Also, I thought of adding a single parent_id column to the person table, but wouldn't that prevent a given person from having multiple parents?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Class::DBI and a self-referencing many-to-many
by perrin (Chancellor) on Sep 14, 2005 at 20:50 UTC | |
by jgallagher (Pilgrim) on Sep 14, 2005 at 21:20 UTC | |
by perrin (Chancellor) on Sep 14, 2005 at 21:28 UTC |