I also tried using DBIx::Class::Tree::AdjacencyList...
Using this module I defined my parent_id in my Users.pm schema like:

 __PACKAGE__->parent_column('parent_id');


And then I can get all children of one user like:

my $user_id = 7;
my $thisuser = $c->model('MyDB::Users')->find({ user_id=> $user_id });
my $children = $thisuser->children();

But this gives me only a list of children one level under $thisuser and it's the same
as executing only:

my $children = $c->model('MyDB::Users')->find({ parent_id=> $user_id });

So it's no big deal.. Still this module is OK because it maintains consistency of the tree when you delete one branch for example, but I still haven't found the solution I need - listing all children in all levels under one parent as well as checking if
a single user is a (grand)parent who can edit a certain user...

When listing all children it would also be necessary if I could specify order (e.g. order by username)
and also limit and offset for pagination on website...


John Napiorkowski wrote:
-
You might want to look at: http://search.cpan.org/dist/DBIx-Class-Tree/

Which is a bit of a different solution than the one you outlined, but I've 
personally had too much trouble with self-referential tables and prefer this 
kind of solution.  I find it's easier to descend through multiple levels 
without creating insane joins on joins.

I know you are using postgresql, but there's a decent explanation of this 
method at: http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

--John

JC._______________________________________________
List:
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive:
http://www.grokbase.com/group/[EMAIL PROTECTED]


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

Reply via email to