Hi,
in a detailed record view i would like to show a list of related records of another table. I want to do this using a global definition.
This is my code.
sub {
my $tags = shift;
my $db = $tags->{db};
my $id = $tags->{ID};
my $table = $DB->table('sreviews');
$table->select_options ('ORDER BY create_date', 'LIMIT 5');
my $sth = $table->query({ reviewd_id => $id} );
if ($sth) {
my @output;
while (my $row = $sth->fetchrow_hashref) {
push (@output, $row);
}
return {rev_loop => \@output };
}
}
In the detailed template I use
<%loop rev_loop%> <%sreview_id%>: <%review%><br><%endloop%>
But i get this error message:
What am I doing wrong?
Thanks for your help!
Henning
in a detailed record view i would like to show a list of related records of another table. I want to do this using a global definition.
This is my code.
Code:
show_reviews sub {
my $tags = shift;
my $db = $tags->{db};
my $id = $tags->{ID};
my $table = $DB->table('sreviews');
$table->select_options ('ORDER BY create_date', 'LIMIT 5');
my $sth = $table->query({ reviewd_id => $id} );
if ($sth) {
my @output;
while (my $row = $sth->fetchrow_hashref) {
push (@output, $row);
}
return {rev_loop => \@output };
}
}
In the detailed template I use
Code:
<%show_reviews%> <%loop rev_loop%> <%sreview_id%>: <%review%><br><%endloop%>
But i get this error message:
Quote:
Can't call method "fetchall_arrayref" on an undefined value at c:/home/henning/test/cgi-bin/dbsql201/admin/GT/SQL/Table.pm line 683.What am I doing wrong?
Thanks for your help!
Henning