[Dbix-class] DBIx::Class and hierarchy (trees)

jakac jakac at iprom.si
Wed Jun 4 16:43:58 BST 2008


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 =3D 7;
my $thisuser =3D $c->model('MyDB::Users')->find({ user_id=3D> $user_id });
my $children =3D $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 =3D $c->model('MyDB::Users')->find({ parent_id=3D> $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'v=
e personally had too much trouble with self-referential tables and prefer t=
his kind of solution.  I find it's easier to descend through multiple level=
s 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/dbix-class@lists.rawmode.org
>>     =

>
>
>       =

>
> _______________________________________________
> 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/dbix-class@lists.rawmod=
e.org
>
>   =

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20080604/7b9=
51773/attachment-0001.htm


More information about the DBIx-Class mailing list