in reply to Re^3: How to reach each element of 2d-array retrieved from Mysql query?
in thread How to reach each element of 2d-array retrieved from Mysql query?

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

Replies are listed 'Best First'.
Re^5: How to reach each element of 2d-array retrieved from Mysql query?
by davorg (Chancellor) on May 25, 2006 at 08:41 UTC

    Again, this is all guesswork based on reading the documentation.

    my $sth = $dbh->query("select a, b from c where d=1"); while (my @row = $sth->fetchrow) { push @data, \@row; }
    Will I have a column, and not a row?

    You'll have a 2-dimensional array of rows and columns (or, more accurately, an array of rows where each element contains a reference to an array containing all of the columns from one record in the database).

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

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

      Well. Is this not correct in order to reach a row: print $$data[0].' '.$$data[1]; ? I just get blank! Although $data[0], $data1 contains ARRAY(0x1849f14) ARRAY(0x185bf44).
Re^5: How to reach each element of 2d-array retrieved from Mysql query?
by davorg (Chancellor) on May 25, 2006 at 08:38 UTC
    PS I don't know how to use code-tags...

    Your time at Perl Monks will be far more productive and enjoyable if you make the effort to learn.

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

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

      Thank You, I will!