// 注意:
// bindParam是绑定一个PHP变量到一个SQL参数.是引用方式传递
// 所以你可以改变变量值,再执行.就赋给SQL语句不同的值
// 注意与bindValue的区别
try {
$sql = 'UPDATE `pdo` set `user` = :user, `email` = :email WHERE `id` = :id';
$pre = $dbh->prepare($sql);
// 此处bindParam.执行一次更改id=2,执行一次更改id=3.结果不一样
$user = "ncat2";
$email = "ncat2@gmail.com";
$id = 2;
$pre->bindParam(':user', $user, PDO::PARAM_STR);
$pre->bindParam(':email', $email, PDO::PARAM_STR);
$pre->bindParam(':id', $id, PDO::PARAM_INT);
$pre->execute();$user = "ncat3";
$email = "ncat3@gmail.com";
$id = 3;
$pre->execute();
unset($user, $email, $id);
// 此处bindValue. 执行两次id=4的SQL$user = "ncat4";
$email = "ncat4@gmail.com";
$id = 4;
$pre->bindValue(':user', $user, PDO::PARAM_STR);
$pre->bindValue(':email', $email, PDO::PARAM_STR);
$pre->bindValue(':id', $id, PDO::PARAM_INT);
$pre->execute();
$user = "ncat5";
$email = "ncat5@gmail.com";
$id = 5;$pre->execute();
} catch (PDOException $e)
{var_dump($e);}