What is the difference between bindParam and bindValue?

后端 未结 7 1274
一向
一向 2020-11-22 00:23

What is the difference between PDOStatement::bindParam() and PDOStatement::bindValue()?

7条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 01:18

    From Prepared statements and stored procedures

    Use bindParam to insert multiple rows with one time binding:

    prepare("INSERT INTO REGISTRY (name, value) VALUES (?, ?)");
    $stmt->bindParam(1, $name);
    $stmt->bindParam(2, $value);
    
    // insert one row
    $name = 'one';
    $value = 1;
    $stmt->execute();
    
    // insert another row with different values
    $name = 'two';
    $value = 2;
    $stmt->execute();
    

提交回复
热议问题