Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Mellow Fonks,
It frustrates me that I cannot discover the solution to this problem and so risk annoying people posting what I don't think is strictly a DBI question.

For instance,  $sth->fetchall_arrayref({}) is something I have learned to love, except when returning results from joined tables where field names from different tables collide, clobbering keys in the hash. Apart from using AS in my SELECT statements, how can I convince DBI to return full table.column type field names. I thought that $dbh->{FetchHashKeyName} = might be my answer but it would seem not.

For example purposes only:

my $sth = $dbh->prepare( qq|SELECT,, request +s.requestor,, FROM requests LEFT JOIN requestors ON requests.requestor =| ); my $list = $sth->fetchall_arrayref({});

Update:on Feb 14, 2005 at 21:36 GMT-10
The mapping field names to indexes idea, with my screwy logic below (untested).

my $sth = $dbh->prepare( qq|SELECT, request.daterequested, request.requestor +, request.producer,,,, producer.e +mail LEFT JOIN requestor ON request.requestor = LEFT JOIN producer ON request.producer = | ); my @mapping = qw/ request.daterequested request.requestor r +equest.producer ; $sth->execute(); my $arrayref = $sth->fetchall_arrayref(); my @mapped = map { my %mapto; @mapto{@mapping} = @$_; \%mapto; } @$arrayref;

I can't believe it's not psellchecked

In reply to DBI, mysql, SELECT with JOIN and field names by submersible_toaster

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (7)
    As of 2019-07-23 04:50 GMT
    Find Nodes?
      Voting Booth?
      If you were the first to set foot on the Moon, what would be your epigram?

      Results (24 votes). Check out past polls.