[dancer-users] Iteration of hash in template.

Richard Reina gatorreina at gmail.com
Wed Sep 30 20:36:03 BST 2015


2015-09-30 14:25 GMT-05:00 WK <wanradt at gmail.com>:

> Hi!
>
> 2015-09-30 22:20 GMT+03:00 Richard Reina <gatorreina at gmail.com>:
>
> > Matched_pats.keys.sort %>. However, In this case though the template only
> > displays one row because each resulting row in the SQL query all have the
> > same ID number. Is there any simple change I can make to get the results
> to
> > fully iterate?
>
> How could you have hash(ref), where are multiple keys named by same ID?
>
> Could you show your datastructure?
>
>    $q = 'SELECT l.ID,
         c.ID AS CHLG_ID, c.season, c.YEAR,
         g.date, g.opp_team,
         a.NAME AS ANAME,
         ch.NAME AS CHNAME,
         p.AMOUNT,
         u.screenname AS SPONSOR
         FROM game g, accomp_type a, logro l
         LEFT JOIN challenge c ON l.ACC_TYPE_ID=c.ACC_TYPE_ID
         LEFT JOIN patrocinio p ON c.ID=p.CHLNG_ID
         LEFT JOIN charity ch ON c.CHAR_ID=ch.ID
         LEFT JOIN patron pn ON p.PTRN_ID=pn.ID
         LEFT JOIN usuario u ON pn.USER_ID=u.ID
         WHERE l.GAME_ID=?
         AND l.status=?
         AND g.ID=l.GAME_ID
         AND YEAR(g.DATE)=c.YEAR
         AND MONTH(g.date) IN (?, ?, ?)
         AND l.ACC_TYPE_ID=a.ID';

$sth = $dbh->prepare($q);
         $sth->execute($self->{_game_id}, $self->{_logro_status},
@$season_mo[0], @$season_mo[1], @$season_mo[2]);
         my $pats_ref = $sth->fetchall_hashref('ID');
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150930/60969e0a/attachment.html>


More information about the dancer-users mailing list