Which of these two is the safe method to write a query?
$stmt = $pdo->prepare("UPDATE tableName SET fieldName = 0");
OR
$stmt = $pdo->prepare("UPDATE tableName SET fieldName = :parameter");
$stmt-> bindValue(':parameter', 0);
I know the 2nd method is way best and I use it whenever I use a $variable
in bindValue
. But here, I need to use a known integer 0
. So, the first process seemed easier as I did not had to write another bindValue
statement. But, is it safe?