Gossamer Forum
Home : General : Perl Programming :

Re: [RedRum] $sth->fetchall_array

Quote Reply
Re: [RedRum] $sth->fetchall_array In reply to
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
Subject Author Views Date
Thread $sth->fetchall_array Paul 11056 Sep 27, 2001, 2:41 PM
Post Re: [RedRum] $sth->fetchall_array
tandat 10904 Sep 27, 2001, 7:48 PM
Thread Re: [RedRum] $sth->fetchall_array
Wil 10966 Sep 28, 2001, 2:11 AM
Post Re: [Wil] $sth->fetchall_array
Paul 10924 Sep 28, 2001, 3:31 AM
Thread Re: [Wil] $sth->fetchall_array
Paul 10896 Sep 28, 2001, 1:48 PM
Post Re: [RedRum] $sth->fetchall_array
Wil 10856 Sep 29, 2001, 6:59 AM