数据分析师2017-10-01 00:20:33
How to implement parameter passing in PDO - Q&A on PHP Chinese website - How to implement parameter passing in PDO - Q&A on PHP Chinese website
Take a look around and learn.
PHP中文网2017-08-18 14:04:19
Methods bindParam() and bindValue() are very similar.
The only difference is that the former uses a PHP variable to bind parameters, while the latter uses a value.
So when using bindParam, the second parameter can only use variable names, not variable values, while bindValue can only use specific values.
The code is as follows:
$stm = $pdo->prepare("select * from users where user = :user"); $user = "jack"; //正确 $stm->bindParam(":user",$user); //错误 //$stm->bindParam(":user","jack"); //正确 $stm->bindValue(":user",$user); //正确 $stm->bindValue(":user","jack");
In addition, in the stored procedure, bindParam can be bound as an input/output variable