PDOStatement::bindParam()
和 PDOStatement::bindValue()
有什么区别?
最佳答案
答案在 bindParam
的文档中:
和 execute
例子:
$value = 'foo';
$s = $dbh->prepare('SELECT name FROM bar WHERE baz = :baz');
$s->bindParam(':baz', $value); // use bindParam to bind the variable
$value = 'foobarbaz';
$s->execute(); // executed with WHERE baz = 'foobarbaz'
要么
$value = 'foo';
$s = $dbh->prepare('SELECT name FROM bar WHERE baz = :baz');
$s->bindValue(':baz', $value); // use bindValue to bind the variable's value
$value = 'foobarbaz';
$s->execute(); // executed with WHERE baz = 'foo'
关于php - bindParam 和 bindValue 有什么区别?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1179874/