May 2005
Intermediate to advanced
352 pages
14h 39m
English
fetchrow_arrayref( )
$statement_handle->fetchrow_arrayref( )This returns a reference to a place in
memory containing an array of one row from the results of a statement
handle. There are no arguments for this function.
It's synonymous with fetch( ).
...
my $sql_stmnt = "SELECT title, author FROM books";
my $sth = $dbh->prepare($sql_stmnt);
$sth->execute( );
while (my $book = $sth->fetchrow_arrayref( )) {
my ($title, $author) = @$book;
print "$title by $author \n";
}
$sth->finish( );Notice that fetchrow_arrayref( ) is reused at the
beginning of each pass through the while
statement. This is because a reference to one row is retrieved at a
time.
Read now
Unlock full access