in reply to sql record sets
my $sth = $dbh->prepare("SELECT * FROM foo"); $sth->execute(); while (my $row = $sth->fetchrow_arrayref()) { # Use @$row like $row->[0], $row->[1], etc. } $sth->finish(); # Important!
my $rows = $dbh->selectall_arrayref("SELECT * FROM foo"); # Now @$rows contains all the row data. # Use @$rows like $rows->[$row_number]->[$column_number]... foreach my $row (@$rows) { # ...or @$row like $row->[$column_number] } # Repeat as required, as long as $rows is still defined. # $sth->finish(); # Update per pope (Not required, no $sth defined)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: sql record sets
by pope (Friar) on Sep 16, 2002 at 08:30 UTC |