<div dir="ltr">Correction on my syntax, for reference.<br><pre class=""><span class="">$sth</span> <span class="">=</span> <span class="">$dbh</span><span class="">-></span><span class="">prepare</span><span class="">(</span><span class="">"SELECT foo, bar, baz FROM table"</span><span class="">)</span><span class="">;</span>
<span class="">$sth</span><span class="">-></span><span class="">execute</span><span class="">;</span>
<span class="">$hash_ref</span> <span class="">=</span> <span class="">$sth</span><span class="">-></span><span class="">fetchall_hashref</span><span class="">(</span> <span class="">[</span> <a href="http://perldoc.perl.org/functions/qw.html"><span class="">qw</span></a><span class="">(</span>foo bar<span class="">)</span> <span class="">]</span> <span class="">)</span><span class="">;</span>
<a href="http://perldoc.perl.org/functions/print.html"><span class="">print</span></a> <span class="">"For foo 42 and bar 38, baz is $hash_ref->{42}->{38}->{baz}<span class="">\n</span>"</span><span class="">;<br></span></pre><pre class=""><span class=""> Almost!<br><br><br></span></pre><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 1, 2015 at 9:35 AM, Richard Reina <span dir="ltr"><<a href="mailto:gatorreina@gmail.com" target="_blank">gatorreina@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="h5"><br><div class="gmail_extra"><br><div class="gmail_quote">2015-09-30 18:00 GMT-05:00 Yitzchak Scott-Thoennes <span dir="ltr"><<a href="mailto:sthoenna@gmail.com" target="_blank">sthoenna@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>On Wed, Sep 30, 2015 at 2:41 PM, Richard Reina <<a href="mailto:gatorreina@gmail.com" target="_blank">gatorreina@gmail.com</a>> wrote:<br>
> Well something somewhat strange has happened. When I do: print<br>
> Dumper($pats_ref) . "\n"; from the perl module that handles the DB query it<br>
> only prints one row:<br>
><br>
> $VAR1 = {<br>
> '8' => {<br>
> 'ID' => '8',<br>
> 'ANAME' => 'KOB',<br>
> 'opp_team' => 'Cardinals',<br>
> 'YEAR' => '2015',<br>
> 'date' => '2015-09-04',<br>
> 'AMOUNT' => '2.00',<br>
> 'IDD' => '3',<br>
> 'CHNAME' => 'DWB',<br>
> 'CHLG_ID' => '12',<br>
> 'SPONSOR' => 'MPK',<br>
> 'season' => 'Fall'<br>
> }<br>
> };<br>
><br>
> This is baffling and very frustrating because when I do the exact same query<br>
> from the MySQL console it yields 3 row and not 1 row.<br>
><br>
> ID | CHLG_ID | season | YEAR | date | opp_team | NAME | NAME<br>
> | AMOUNT | sponsor |<br>
> +----+---------+--------+------+------------+----------+-----------+-----------------------------+--------+---------+-------------<br>
> | 8 | 9 | Fall | 2015 | 2015-09-04 | Cardinals | KOB | AFA<br>
> | 2.00 | MPK |<br>
> | 8 | 12 | Fall | 2015 | 2015-09-04 | Cardinals | KOB | DWB<br>
> | 1.00 | RFR |<br>
> | 8 | 12 | Fall | 2015 | 2015-09-04 | Cardinals | KOB | DWB<br>
> | 2.00 | MPK |<br>
> +----+---------+--------+------+------------+----------+-----------+-----------------------------+--------+---------+<br>
><br>
> Any insight as to why this might be happening would be greatly, greatly<br>
> appreciated.<br>
<br>
</div></div>You are telling DBI to put the results in a hash by ID. So later rows<br>
overwrite earlier ones.<br>
<br>
You probably want fetchall_arrayref( {} ) instead of fetchall_hashref,<br>
but I don't remember seeing what you want to end up doing with the<br>
data.<br></blockquote></div><br></div></div></div><div class="gmail_extra">Yitzchak,<br><br></div><div class="gmail_extra">I cannot thank you enough for your suggestion. Yes, fetchall_arrayref( {} ) worked perfectly. I still do not have a good understanding as to when to use fetchall_hashref and when to opt for fecthall_arrayref() instead. I really really appreicate your help in getting me straightened out.<br><br></div><div class="gmail_extra">Thank you again.<br></div></div>
<br>_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" rel="noreferrer" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
<br></blockquote></div><br></div>