Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Oh help me please Holy Monks, this one is killing me.

I have an old pm module that does all the connecting and querying with MySQL, so I have faith in it.

Now I am trying to retrieve multiple rows with all columns using selectall_hashref and am tripping all over myself.

my $data_all =  $connection->selectall_hashref($query, { 'Columns' => {} } );

And I get back: Not an ARRAY reference at /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/DBI.pm line 2106.

I know all the column names, this is not a read any strange table function.

Somewhere my approach has it all wrong, should I take a different approach?

What I am trying to get back is an array of hash references, that's al, to my multiple row query, and yes my query works manually.

Can you help me?

p.s. I found this thread <a href="https://www.perlmonks.org/?node_id=1040177 "target="_blank> How does DBI return an arrayref with key/value pairs? so I tried that, switching to selectall_arrayref

But when I ran

for my $row (@$data_all)<br> {<br> my %currec = $row;<br> foreach my $columns (keys %currec){<br> say $columns;<br> say $currec{$columns};<br> }<br> }

What I got back was that $columns was another hash, and that led my second "say" to output nothing.

So confused


In reply to Having problems with DBI selectall_arrayref by SergioQ

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-25 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found