PDO 怎么实现传参
魂归战袍
魂归战袍 2017-02-15 16:23:23
0
4
984
魂归战袍
魂归战袍

繁华落尽只为一人等待

reply all(4)
数据分析师

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.

Ty80

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

Ty80

Welcome to php Chinese website I am Ty80.

Ty80

Can you be more specific

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template