Name
selectrow_array( )
Synopsis
$database_handle
->selectrow_array($sql_statement
[, \%attributes
, @values
])
This returns one row from
the results of an SQL statement in the form of an array, where each
column returned is represented by an element of the array, in order.
This method combines prepare( )
, execute()
, and fetchrow_array( )
. No statement
handle is created, so finish( )
is unnecessary. 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 ($title, $author) = $dbh->selectrow_array( $sql_stmnt, undef, '1234'); print "$title by $author \n";
No attributes are given for the SQL statement, so
undef
is used for the second argument. The third
argument provides the book_id number for the
placeholder in the SQL statement.
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.