search

Home  >  Q&A  >  body text

PDO 怎么实现传参

魂归战袍魂归战袍2890 days ago998

reply all(4)I'll reply

  • 数据分析师

    数据分析师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.

    reply
    0
  • PHP中文网

    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

    reply
    0
  • PHP中文网

    PHP中文网2017-08-18 14:00:47

    Welcome to php Chinese website I am Ty80.

    reply
    0
  • PHP中文网

    PHP中文网2017-08-18 13:58:59

    Can you be more specific

    reply
    0
  • Cancelreply