RE: [htmltmpl] Adding to a row in a loop
Brought to you by:
samtregar
From: Chris D. <Chr...@Ma...> - 2002-08-06 09:30:42
|
Kenny Smith wrote, on Tuesday, August 06, 2002 1:24 AM > while( $data = $sth->fetchrow_hashref() ) { > push( @{$rows} , $data ) ; > } The DBI documentation explicitly warns against storing the result from fetchrow_hashref() as part of a fetch loop: Currently, a new hash reference is returned for each row. This *will* *change* in the future to return the same hash ref each time, so don't rely on the current behaviour. This means that you should copy the result from fetchrow_hashref to your array, for example: while (my $data = $sth->fetchrow_hashref ('NAME_lc')) { push (@$rows, { $data }); } Better still, take the effort out of your code and let the (new) function fetchall_arrayref do it all for you: my $rows = $sth->fetchall_arrayref ({}); Chris -- Chris Davies, Manheim Online Tel. 0113 393-2004 Fax. 0870 444-0482. Mobile 07778 199069 |