Name
selectall_arrayref( )
Synopsis
$database_handle
->selectall_arrayref($statement
, \%attributes
, @bind_values
)
This returns a reference to
an array of references to arrays containing data for each row
retrieved from the results of an SQL statement given. This method
combines prepare( )
, execute()
, and fetchall_arrayref( )
. An optional
second argument can specify any of the attributes allowed for a
statement handle. If placeholders are used in the SQL statement,
their values must be given as an array for the third argument.
my $sql_stmnt = "SELECT title, author FROM books WHERE book_id = ?"; my $books = $dbh->selectall_arrayref($sql_stmnt, undef, '1234'); foreach my $book (@$books) { my ($title, $author) = @$book; print "$title by $author \n"; }
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.