[dancer-users] Complex Query ?

David Precious davidp at preshweb.co.uk
Fri Jan 31 16:18:53 GMT 2014


On Fri, 31 Jan 2014 16:47:26 +0100
Hugues <hugues at max4mail.com> wrote:

> Hello  David
> query works well with  $sth->fetchall_arrayref but the result with 
> template toolkit doesn'work.
> 
> return template 'result' => {
>                                    resultC      =>
> $sth->fetchall_arrayref,
> 
> }

Bah, sorry.  That will return an arrayref of arrayrefs, one per DB
row.  Usually you'll want an arrayref of hashrefs, which is what your
template code is expecting.

The somewhat unintuitive syntax for that is:

$sth->fetchall_arrayref({});

Passing it an empty hashref as the slice param asks for each row to be
returned as a hashref.  See the DBI docs for further info.


-- 
David Precious ("bigpresh") <davidp at preshweb.co.uk>
http://www.preshweb.co.uk/     www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan        www.preshweb.co.uk/github




More information about the dancer-users mailing list