Example 1: Repeated inserts using prepared statements
This example performs an INSERT query by substituting a name and a value for the named placeholders.
This example performs an INSERT query by substituting a name and a value for the named placeholders.
<?php
$stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)");$stmt->bindParam(':name', $name);$stmt->bindParam(':value', $value);
// insert one row$name = 'one';$value = 1;$stmt->execute();
// insert another row with different values$name = 'two';$value = 2;$stmt->execute();?>
0 comments:
Post a Comment