in reply to Re: DBI Select results confussion
in thread DBI Select results confussion

I thought I knew of two separate ways for retriving data from a query..

1.Use bind, for example:

$query_is->bind_columns(\$count_is);

2.Use fetchrow_array(), for example:

@row = $query_is->fetchrow_array

.. could you (or someone else) show me how to use "bind" regarding the example in my first posting.

When I do bind (same code as in my original posting) but without the "fetchrow_array" line it does not output any data? i.e it only outputs data if I do the fetchrow_array command.

Thanks

M

Replies are listed 'Best First'.
Re: Re: Re: DBI Select results confussion
by dws (Chancellor) on Nov 10, 2002 at 21:22 UTC
    When I do bind (same code as in my original posting) but without the "fetchrow_array" line it does not output any data? i.e it only outputs data if I do the fetchrow_array command.

    O.K., I think I see where the misunderstanding is. You're trying to arrange to have the result of the query show up in a variable. There are two ways to do that: you can do the appropriate binding to cause the result of a fetch to get stuffed into a variable, or you can fetch a row (either as an array or as a hash) and extract the value manually. You're trying to do the former; my snippet does the latter.

    In both cases, unless a row is fetched, there's no value there to get. Hence you need to force a fetch.

    I avoid using bind_column() et al. because I find the resulting code is harder to follow. Readers can easily follow code that manually fetches a row and extracts values, but using column binding forces readers to remember that there's a magic wormhole in that region of space that causes values to automagically appear elsewhere.

      Thanks for bearing with me whilst I explained my posting! And thanks for replying and making it clear!

      M