Name

fetchrow_hashref( )

Synopsis

$statement_handle->fetchrow_hashref( )

This returns a reference to a place in memory containing a hash of keys and values for one row from the results of a statement handle. There are no arguments for this function.

...
my $sql_stmnt = "SELECT title, author FROM books";
my $sth = $dbh->prepare($sql_stmnt);
$sth->execute( );
while (my $book_ref = $sth->fetchrow_hashref( )) {
   print "$book_ref->{'title'} by $book_ref->{'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.