(Sorry for the long delay; I got bushwhacked by Real Life, but managed to survive it.)

I'd tried using selectall_hashref originally - that is, in fact, the first approach I tried - but I recall being unsatisfied with the output. I just went back and reproduced what I'd done then, and the problem turns out to be that either the docs don't tell you how to do what I need to do, or it just can't be done with selectall_hashref. In short, here are the problems:

1) Remapping that hashref into the arrayref that I want isn't any easier than what I was looking for - unless I've missed something.

2) The output format is... graceless. Perhaps it is, as you say, that I'm missing something - but I want two columns as an arrayref keyed by date, and what selectall_hashref returns is

'2007-05-13' => { subject => 'foobar', date => '2007-05-13', # Erm... label => 'xyz' }

The statement that I'm using is one I showed previously:

my $ref = $dbh->selectcol_arrayref( "select date, label, subject from travel where date >= curdate()-5 + order by date", { Columns=>[1,2,3] } );

If you can show me how to do this better with selectall_hashref, I'd be grateful.


In reply to Re^4: Elegance, dammit! by oko1
in thread Elegance, dammit! by oko1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.