Hello all! This is mostly a reason that DBIC is excellent; consider showing it to people who are die hard SQLers :-)
So here is my table structure: User has many Roles (Role belongs to User) Role has many Permissions (Permission belongs to) Permissions has many Screens (Screens has many Permissions) Screens belongs to Section (Section has many Screens) So I thought I could do this: my @sections = $user->roles ->related_resultset('permissions') ->related_resultset('screens') ->related_resultset('section') ->all; But related_resultset apparently doesn't work with many_to_many? The following is *close* to what I wanted my @sections = $user->roles ->related_resultset('role_permissions') ->related_resultset('permission') ->related_resultset('permission_screens') ->related_resultset('screen') ->related_resultset('section') ->all; But it turns out it returns a section per role, which often means duplicates. So I figured I could do a distinct, so I finally tried this: my @sections = $user->roles ->related_resultset('role_permissions') ->related_resultset('permission') ->related_resultset('permission_screens') ->related_resultset('screen') ->related_resultset('section') ->search(undef, { distinct => 1 }); And it worked! Hurray DBIC! -- fREW Schmidt http://blog.afoolishmanifesto.com
_______________________________________________ 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.scsys.co.uk