I have been reusing the same variable $stmt
in my PHP script to write prepared statements:
$stmt = $dbh->prepare("SELECT column_A FROM Table1 WHERE id=?");
$stmt->bindValue(1, $id, PDO::PARAM_INT);
$stmt->execute();
....
$stmt = $dbh->prepare("UPDATE Table2 SET column_B=? WHERE column_A=?");
$stmt->bindValue(1, $name);
$stmt->bindValue(2, $column_A);
$stmt->execute();
My question is, how do I know if the two statements are being written to cache and that the second statement did not overwrite the first statement though both statements are sharing the same variable name?
Source: Tips4all, CCNA FINAL EXAM
You don't. But overriding the variable won't change much - you're assigning a new value to the variable, not editing anything.
ReplyDelete