[dancer-users] Iteration of hash in template.

Alex Mestiashvili mailatgoogl at gmail.com
Wed Sep 30 20:40:27 BST 2015


On Wed, Sep 30, 2015 at 9:36 PM, Richard Reina <gatorreina at gmail.com> wrote:

>
>
> 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');
>

Wouldn't be it easier to see the structure of the hash with Data::Dumper?
Could you please paste the output of debug Dumper($pats_ref); ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150930/1dc60502/attachment.html>


More information about the dancer-users mailing list