in reply to Re: Array of Arrays & Fetchrow
in thread Array of Arrays & Fetchrow

Your right Robartes, your way is probably easier. Thanks for such a detailed explaination of your code, I only really used fetchrow_array until now, because I'm not too confortable with references.

Where there's a Willman, there's a way!

Replies are listed 'Best First'.
Re: Re: Re: Array of Arrays & Fetchrow
by Willman023 (Scribe) on Nov 01, 2002 at 17:21 UTC
    I may have spoke to soon. I used robartes code:

    push @rows, $_ for $ratings->fetchrow_arrayref(); print XML "$rows[0]->[0]:$rows[0]->[1]:$rows[1]->[0]:$rows[1]->[1]\n";
    And my output is 1111:1::

    So I added a: push @rows, $_ for $ratings->fetchrow_arrayref(); This is to get the second line from the DB.

    And my output is 2222:2:2222:2 instead of 1111:1:2222:2 like I thought it would be. Can anybody tell me what I'm doing wrong here?
    Thanks

    BW

      Hi, something's fishy indeed - probably my fault :). If you print the values of @rows after the push, what does it say (should say ARRAYREF(0x.....) )?

      CU
      Robartes-

        After the first push it prints out:

        1 : 1111

        After the second push its like:

        2 : 2222
        2 : 2222

        So I'm thinking I'm loosing the reference to the first entry 1 : 1111. But for my purposes I need to be able to access this list after the loop. So do I need fetchrow_array instead of fetchrow_arrayref to be able to keep the previous entries? And if so, how would that change the syntax of the embeded array? Thanks alot! bW