Re: moving from mySQL to pgsql, need a bit of help (perl)

From: Peter Haworth <pmh(at)edison(dot)ioppublishing(dot)com>
To: Ed Loehr <eloehr(at)austin(dot)rr(dot)com>
Cc: Matt Housh <jaeger(at)morpheus(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: moving from mySQL to pgsql, need a bit of help (perl)
Date: 2000-07-11 12:31:39
Message-ID: ML-3.4.963318699.886.pmh@edison.ioppublishing.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ed Loehrwrote:
> I believe DBI/DBD does this for you:
>
> while ($row_href = $sth->fetchrow_hashref)
> {
> push( @taghash, $row_href);
> }

Don't do that! Each hashref in that array will point to the same hash in some
future version of the DBI. You should do this instead:

while($row=$sth->fetchrow_hashref){
push @taghash,{%$row};
}

Or, better yet:

$taghash=$sth->fetchall_arrayref({});

to get everything all in one go.

--
Peter Haworth pmh(at)edison(dot)ioppublishing(dot)com
"Master, does Emacs have the Buddha nature?" the novice asked.
The Chief Priest had been in the temple for many years and could be
relied upon to know these things. He thought for several minutes before
replying, "I don't see why not. It's got bloody well everything else."

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2000-07-11 12:58:38 Re: [GENERAL] Slashdot discussion
Previous Message The Hermit Hacker 2000-07-11 12:28:03 Re: Slashdot discussion