Placeholders and Statement Handles
Many database drivers allow you to use question marks
as placeholders in SQL statements and then bind values to the
placeholders before executing them. This enables you to prepare a
single statement with placeholders and reuse it for each row of the
database. For example, the prepare
statement might read:
$st_handle = $db_handle->prepare(q{ insert into books (isbn, title) values (?, ?) }) || die db_handle->errstr;
And a subsequent execute
statement might read:
$st_handle->execute("1-56592-286-7", "Perl in a Nutshell") || die $db_handle->errstr;
Get Perl in a Nutshell, 2nd Edition 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.