On Tue, Sep 11, 2001 at 05:05:37PM -0400, Rob Ransbottom wrote:
> On Tue, 11 Sep 2001, Wilson, Doug wrote:
>
> > > Why will fetchrow_hashref change in the future
> > > to return the same reference each time?
>
> > The idea is that it takes time to create a new hash, and
> > it is quicker to just reuse the old hash. If you are
> > just fetching and processing one record at a time, then
> > you will benefit.
>
> This I understand. But it seems that the purpose of
> fetchrow_hashref is to iterate through the results
> without committing to grabbing them all. This seems
> to imply more than one row, especially as there is
> no selectrow_hashref.
There is now (I think).
> If I want a hashref it seems that in all but exceptionally
> well defined situations I would need a unique ref.
>
> I suppose the idea is that it is handy to slide down
> through your results throwing stuff away until you
> find the one you want.
Yes. Or calling some other function with some values from each row.
And many people like to use hashes when selecting many columns
just to save defining loads of individual variables.
> Given how fetchall_arrayref( $hash_ref) works (and relates
> to fetchrow_hashref) such a change seems confusing.
>
> Is there some thought that the actual hash will be partly
> preserved, thus saving time?
Yes.
Though my plan now is to only return the same ref for each row
if the user does $h->{FetchHashReuse} = 1.
Tim.