This is probably bread 'n butter to you but ........

I have the following table relationships .....

groups ---< categories ---< subcategories ----< products

for a group, I want to retrieve all of its categories, the catgeories' subcats 
etc.

i have this .........

## switch between list and rs context
my $group_rs =
my @group = $schema->resultset('ProductGroup')->search( { 'me.id' => 18 }, 
                                                           { select => [ 
'me.name', 'categories.name', 'subcategories.name', 'products.name'],
                                                                as => [ 
qw|group_name category_name subcategory_name product_name|],
                                                               join => { 
categories => { subcategories => 'products' }}
                                                           });

....... which I think is right but I can;t get at all the rows from the 
returned resultset. If I return a list, it works. $group_rs->next() in a loop 
just returns the first row.

## this works in ist context
foreach my $group ( @groups ) {
    my $group_name  = $group->get_column('group_name');
    my $cat_name    = $group->get_column('category_name');
    my $subcat_name = $group->get_column('subcategory_name');
    my $prod_name   = $group->get_column('product_name');
    print "$group $group_name => $cat_name => $subcat_name => $prod_name\n";    
}

=pod    
 ## this doesn't work for all rows context                                      
                
foreach my $group ( $group_rs->next() ) {
    my $group_name  = $group->get_column('group_name');
    my $cat_name    = $group->get_column('category_name');
    my $subcat_name = $group->get_column('subcategory_name');
    my $prod_name   = $group->get_column('product_name');
    print "$group $group_name => $cat_name => $subcat_name => $prod_name\n";
}
=cut

I'd like to use the rs copntext and print something like .........

group1
  cat1
     subcat1
         prod1
          prod2
         prod3
      subcat2
        prod4
      subcat3
         prod5
  cat2
     subcat4
        ..... etc. etc.

Any tips would be greatly/warmly appreciated.

-Ants

                
---------------------------------
 Yahoo! Messenger - with free PC-PC calling and photo sharing.
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to