Name
fetchall_arrayref( )
Synopsis
$statement_handle
->fetchall_arrayref( )
This captures the results of a statement and returns a reference to the data. The results is a complex data structure; an array of references to an array for each row of data retrieved.
... my $sql_stmnt = "SELECT title, author FROM books"; my $sth = $dbh->prepare($sql_stmnt); $sth->execute( ); my $books = $sth->fetchall_arrayref( ); $sth->finish( ); foreach my $book (@$books) { my ($title, $author) = @$book; print "$title by $author \n"; } $sth->finish( );
Get MySQL in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.