in reply to Re^2: Class::DBI and a self-referencing many-to-many
in thread Class::DBI and a self-referencing many-to-many

Your syntax for adding parents looks correct, or you could just call create() on your linking table directly. What is it that you don't like about it? Do you have an example of alternative syntax you'd like to use?

You're right that my parent_id column idea would mean only a single parent. I was thinking of a tree in computer science terms, where a node can only have one parent. What you want is probably a directed graph rather than a tree.

  • Comment on Re^3: Class::DBI and a self-referencing many-to-many

Replies are listed 'Best First'.
Re^4: Class::DBI and a self-referencing many-to-many
by jgallagher (Pilgrim) on Sep 14, 2005 at 21:20 UTC
    my $parent1 = Person->create({ name => 'P1' }); my $parent2 = Person->create({ name => 'P2' }); I guess I was hoping to say something like this:
    my $parent = Person->create({ name => 'P' }); my $child = Person->create({ name => 'C1', parent => $parent });
    But I can live without it. :-)
      Just make your own method that takes these arguments and calls create on both tables.