Name

bind_columns( )

Synopsis

$statement_handle->bind_columns([\%attributes,] @references)

This associates or binds columns from a statement handle to a given list (@references) of variables. The values are updated when the related row is retrieved using a fetch method without extra copying of data. The number of variables given must match the number of columns selected and the columns are assigned to variables in the order the columns are returned. Attributes common to all DBI handles may be stated as the first argument.

...
my $sql_stmnt = "SELECT title, author FROM books";
my $sth = $dbh->prepare($sql_stmnt);
$sth->execute( );
$sth->bind_columns(\$title, \$author);
while($sth->fetch( )) {
   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.