Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm a perl beginner and can't see what is up with the following code
I though each element in the array was a hash ref and i have confirmed this by ref($row) but nothing is being output? The data is there as this works$sql = "select * from table limit 10"; $sth = $db->prepare($sql); $sth->execute() or die "SQL Error: $DBI::errstr\n"; my $rows = $sth->fetchall_arrayref({ Slice => {}}); foreach my $row ( @$rows ) { print $row->{'id'}, "\n"; }
thanks$sth->execute or die "SQL Error: $DBI::errstr\n"; while (@row = $sth->fetchrow_array) { print $row[0], "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem with fetchall_arrayref
by roboticus (Chancellor) on Dec 30, 2010 at 16:14 UTC | |
|
Re: problem with fetchall_arrayref
by derby (Abbot) on Dec 30, 2010 at 23:54 UTC | |
|
Re: problem with fetchall_arrayref
by Anonymous Monk on Dec 30, 2010 at 16:16 UTC | |
by oko1 (Deacon) on Dec 30, 2010 at 18:18 UTC |