What is the difference between PDOStatement::bindParam()
and PDOStatement::bindValue()
?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
For the most common purpose, you should use
bindValue
.bindParam
has two tricky or unexpected behaviors:bindParam(':foo', 4, PDO::PARAM_INT)
does not work, as it requires passing a variable (as reference).bindParam(':foo', $value, PDO::PARAM_INT)
will change$value
to string after runningexecute()
. This, of course, can lead to subtle bugs that might be difficult to catch.Source: http://php.net/manual/en/pdostatement.bindparam.php#94711