This is a bit more complicated because a link can be in multiple categories. Something like this:
sub {
my $ID = $IN->param('ID') || return '';
my $sth = $DB->table('Category','CatLinks')->select( { LinkID => $ID });
my @cats;
while (my $cat=$sth->fetchrow_hashref){
push @cats, $cat;
}
return {Cat_Loop=>\@cats};
}
Code:
sub {
my $ID = $IN->param('ID') || return '';
my $sth = $DB->table('Category','CatLinks')->select( { LinkID => $ID });
my @cats;
while (my $cat=$sth->fetchrow_hashref){
push @cats, $cat;
}
return {Cat_Loop=>\@cats};
}