[英]binding parameters and PDO
If the parameters for statement 1 and 2 are identical, do I need to re-bind, or can I do this? 如果语句1和2的参数相同,我是否需要重新绑定,还是可以执行此操作?
$stmt = $dbh->prepare("SELECT ... thing = :thing ...");
$stmt->bindParam(':thing',$thing);
$stmt->execute();
// do something with data
$stmt = $dbh->prepare("SELECT something else ... thing = :thing ...");
$stmt->execute();
? ?
Assuming you actually mean: 假设你的意思是:
$stmt = $dbh->prepare("SELECT ... thing = :thing ...");
// ...
No , you are assigning $stmt
to a new PDOStatement
object, which does not hold the information that was stored in the old object. 不 ,您将
$stmt
分配给新的PDOStatement
对象,该对象不包含存储在旧对象中的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.