[dancer-users] Iteration of hash in template.

David H untg99 at gmail.com
Thu Oct 1 01:00:02 BST 2015


As far as I know you can do something like this:
$rows_ref = $sth->fetchall_hashref( ['ID', 'AnotherID' ] )

To specify multiple ID's to be unique by, as I've had that same issue in
the past.
Then do a data Dumper to see what the structure looks like.

David

On Thu, Oct 1, 2015 at 8:30 AM, Yitzchak Scott-Thoennes <sthoenna at gmail.com>
wrote:

> On Wed, Sep 30, 2015 at 2:41 PM, Richard Reina <gatorreina at gmail.com>
> wrote:
> > Well something somewhat strange has happened. When I do:  print
> > Dumper($pats_ref) . "\n"; from the perl module that handles the DB query
> it
> > only prints one row:
> >
> > $VAR1 = {
> >           '8' => {
> >                    'ID' => '8',
> >                    'ANAME' => 'KOB',
> >                    'opp_team' => 'Cardinals',
> >                    'YEAR' => '2015',
> >                    'date' => '2015-09-04',
> >                    'AMOUNT' => '2.00',
> >                    'IDD' => '3',
> >                    'CHNAME' => 'DWB',
> >                    'CHLG_ID' => '12',
> >                    'SPONSOR' => 'MPK',
> >                    'season' => 'Fall'
> >                  }
> >         };
> >
> > This is baffling and very frustrating because when I do the exact same
> query
> > from the MySQL console it yields 3 row and not 1 row.
> >
> >  ID | CHLG_ID | season | YEAR | date  | opp_team | NAME  | NAME
> > | AMOUNT | sponsor |
> >
> +----+---------+--------+------+------------+----------+-----------+-----------------------------+--------+---------+-------------
> > |  8 |       9  | Fall   | 2015 | 2015-09-04  | Cardinals    | KOB | AFA
> > |   2.00 | MPK |
> > |  8 |      12 | Fall   | 2015 | 2015-09-04 | Cardinals     | KOB | DWB
> > |   1.00 | RFR  |
> > |  8 |      12 | Fall   | 2015 | 2015-09-04 | Cardinals     | KOB | DWB
> > |   2.00 | MPK |
> >
> +----+---------+--------+------+------------+----------+-----------+-----------------------------+--------+---------+
> >
> >  Any insight as to why this might be happening would be greatly, greatly
> > appreciated.
>
> You are telling DBI to put the results in a hash by ID.  So later rows
> overwrite earlier ones.
>
> You probably want fetchall_arrayref( {} ) instead of fetchall_hashref,
> but I don't remember seeing what you want to end up doing with the
> data.
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20151001/358b4c81/attachment.html>


More information about the dancer-users mailing list