in reply to How to reach each element of 2d-array retrieved from Mysql query?

It's hard to see what you're doing as you didn't put any code tags in you post. But you are using Mysql.pm which is only there for backwards compatibility. You should really look at using DBI and DBD::mysql instead (see here for more information.)

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

  • Comment on Re: How to reach each element of 2d-array retrieved from Mysql query?

Replies are listed 'Best First'.
Re^2: How to reach each element of 2d-array retrieved from Mysql query?
by t-strong (Initiate) on May 25, 2006 at 08:04 UTC
    I know that, thank You! But my problem remains: I got to use Mysql.pm and need to retrieve all the rows I get from the query instead just one. Please, tell me how to do it.

      I don't know anything about Mysql.pm, so all this comes from a quick scan of the documentation, but it looks to me like you are executing the statement and fetching the first row each time you go round the loop. I think you need to call query before you go into the loop.

      And when you get the loop working correctly, you can simplify all of the code within it to:

      push @sect, \@row;
      --
      <http://dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

        Let simplify to this:

        @row=$dbh->Query("select a, b from c where d=1")->FetchRow;

        That returns:

        a1, b1 a2, b2

        And I do get only (a1, b1)?

        So, if You suggest make the query before cycle, then what should I put in the while(), and {push @a, \@row}? - Will I have a column, and not a row?! PS I don't know how to use code-tags...

        Edit: g0n - code tags and formatting