Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
Interview question

What is the difference between bindParam() and bindValue() in PDO? PDO में bindParam() और bindValue() में क्या अंतर है?

Answer
AspectbindParam()bindValue()
Binding typeBy referenceBy value
When value is readAt execute() timeImmediately when called
Use caseVariable may change before executeValue is fixed at bind time
$stmt = $pdo->prepare('SELECT * FROM users WHERE id = :id');
$id = 5;
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$id = 10;
$stmt->execute();
// Uses 10, because bindParam reads at execute time
पहलूbindParam()bindValue()
Binding typeReference द्वाराValue द्वारा
Value कब पढ़ी जाती हैexecute() के समयCall होते ही तुरंत
$stmt = $pdo->prepare('SELECT * FROM users WHERE id = :id');
$id = 5;
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$id = 10;
$stmt->execute();
// 10 use होगा, क्योंकि bindParam execute time पर पढ़ता है

Was this answer clear?