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
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.
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:
In addition, in the stored procedure, bindParam can be bound as an input/output variable
Welcome to php Chinese website I am Ty80.
Can you be more specific