bind_param()
$sth->param(index,values[,\%attr|type])
This function associates or binds a value in an SQL statement
to a placeholder. Placeholders are indicated by ? in
SQL statements and are numbered in the order they appear in the
statement, starting with 1. The first argument indicates which
placeholder to replace with a given value, i.e., the second argument.
The data type may be specified as a third argument. Here is an
example:
...
my $sql_stmnt = "SELECT title, publisher
FROM books WHERE author = ?
AND status = ?";
my $sth = $dbh->prepare($sql_stmnt);
$sth->bind_param(1, $author);
$sth->bind_param(2, $status);
$sth->execute();
while(my ($title,$publisher) = $sth->fetchrow_array()) {
print "$title ($publisher) \n";
}In this example, a placeholder (a question mark) is given in the
SQL statement and is replaced with the actual value of
$author using
bind_param(). This must be done before the
execute() is issued.