in reply to Re: perl DBI question about fetchrow_arrayref()
in thread perl DBI question about fetchrow_arrayref()

Yes ikegami. That's why I asked the question.

"using the same array", what is this same array?

By my original understanding, $ref returned by fetchrow_arrayref() is the reference points to the row returned by fetchrow_arrayref(), so when I used "push", it should be no problem.

After I got the answer from sabari, I realized, that the reference pushed into an array is the reference pointed to the current row that fetchrow_arrayref working on.So all the references is a pushed array pointed to the last record. Did I understand this right?

I don't undertand why perl DBI has created such a seemly unuseful function.

Thank you.
  • Comment on Re^2: perl DBI question about fetchrow_arrayref()

Replies are listed 'Best First'.
Re^3: perl DBI question about fetchrow_arrayref()
by ikegami (Patriarch) on Apr 25, 2010 at 19:35 UTC

    "using the same array", what is this same array?

    The one referenced by the reference returned by a call to fetchrow_array and the one reference by the reference returned by a earlier call to fetchrow_array.

    I don't undertand why perl DBI has created such a seemly unuseful function.

    Efficiency. It can avoid creating new arrays all the time, which in turn, allows it to use bind_col internally.

    And contrary to your claims, it's not unusable.
    If you want just one row at a time, then what's the problem?
    If you want all rows, then why aren't you using selectall?

Re^3: perl DBI question about fetchrow_arrayref()
by runrig (Abbot) on Apr 25, 2010 at 23:06 UTC
    I don't undertand why perl DBI has created such a seemly unuseful function.
    It's only unuseful if you misuse it. I often want to process result sets row by row, and I only care about the current row, not what the last row was. If I want all the results at once, then (as shown) you can use one of the selectall_* methods.