May 2005
Intermediate to advanced
352 pages
14h 39m
English
bind_param( )
$statement_param(index,values[,type])
This 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, the second
argument. The datatype may be specified as a third argument.
...
my $sql_stmnt = "SELECT title, publisher
FROM books WHERE author = ?";
my $sth = $dbh->prepare($sql_stmnt);
$sth->bind_param(1, $author);
$sth->execute( );
while($sth->fetch( )) {
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.
Read now
Unlock full access