Home : General : Perl Programming :

General: Perl Programming: Re: [RedRum] $sth->fetchall_array: Edit Log

Here is the list of edits for this post
Re: [RedRum] $sth->fetchall_array
Code:
$sqlquery= "SELECT Email FROM Members";

$sth = $dbh->prepare($sqlquery);
$sth->execute;
my $records = $sth->fetchall_arrayref({});
$sth->finish();


for my $record (@$records) {

# fieldvalue = $record->{'fieldname'}

}

Or you can define your variables before hand:

Code:
while ($pointer = $sth->fetchrow_hashref) {
$field_value = $pointer->{'field_name'};

print "blah blah $field_value blah";
}

Read the documentation on the use of fetchall_arrayref({});, though. You'll find that fetchrow_arrayref is a faster way to fetch your data.

Wil

Last edited by:

Wil: Sep 28, 2001, 2:12 AM

Edit Log: