gennoob has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm relatively new to both Perl and Catalyst however I've been asked to try to create applications using both. In relation to using databases in my applications, I can't seem to find a simple way to get my queries printed out properly. Supposed I just wanted to say "Select * from posts", I used
my @comments = Test::Model::Guestbook::Posts->search(); $c->stash->{comments} = \@comments;
This however printed out hash references. Removing the \ would print out the size of the array. How would I dereference these hash references. Moreover, is there a more proper way to print my queries? By the way, I'm using Catalyst::Model::DBIC.

Replies are listed 'Best First'.
Re: Catalysts question on database
by holli (Abbot) on Apr 19, 2006 at 08:00 UTC
    Assuming you're using a Template Toolkit View and @comments is an array of hashrefs, you can use a construct like the following in your template:
    <table> [% FOR c = comments %] <tr> <td>c.key1</td> <td>c.key2</td> </tr> [% END %] </table>


    holli, /regexed monk/
      Thanks very much!