官方文档 https://www.php.net/manual/zh/pdostatement.bindparam.php
注意: bindParam 第2个参数 mixed &$variable 是引用传值
正确的用法 ($val by reference):
代码语言:javascript复制<?php
foreach ($params as $key => &$val) {
$sth->bindParam($key, $val);
}
?>
错误的用法 ($val by value, because bindParam needs &$variable):
代码语言:javascript复制<?php
foreach ($params as $key => $val) {
$sth->bindParam($key, $val);
}