Gossamer Forum
Home : Products : DBMan SQL : Discussion :

problem with global function

Quote Reply
problem with global function
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.

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



Subject Author Views Date
Thread problem with global function ktt 1665 Nov 3, 2001, 12:17 PM
Post Re: [ktt] problem with global function
Alex 1618 Nov 3, 2001, 12:38 PM