2ge has asked for the wisdom of the Perl Monks concerning the following question:
Output is:use strict; use warnings; use DBIx::Tree::NestedSet; use DBI; my $dbh = DBI->connect('DBI:mysql:test','root','') or die ($DBI::errstr); my $tree = DBIx::Tree::NestedSet->new( dbh => $dbh, no_locking => 1, table_name => 'db_tree' ); $dbh->do("DELETE from db_tree"); #we can't have more "top" categories, so we create "main" $tree->add_child_to_right( name=>'main' ); while (<DATA>) { chomp; my $hr; for my $item ( split '/' ) { $hr->{last_id} = $tree->add_child_to_right( name => $item, id => $hr->{last_id} ); } } print "\nThe Complete Tree:\n"; print $tree->create_report(); __DATA__ foo/bar bar/foo foo/bar/foo
Ok, now problem - I don't want to have "foo/bar" and "foo/bar/foo" as separate paths, but instead only one: "foo/bar/foo" could anyone help me please ?The Complete Tree: main (354)(1) foo (355)(2) bar (356)(3) bar (357)(2) foo (358)(3) foo (359)(2) bar (360)(3) foo (361)(4)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: duplicates in DB tree
by 2ge (Scribe) on Jun 14, 2005 at 13:31 UTC | |
|
Re: duplicates in DB tree
by thcsoft (Monk) on Jun 14, 2005 at 13:21 UTC | |
by 2ge (Scribe) on Jun 14, 2005 at 13:33 UTC |