I am trying to implement an update statement using a prepared statement in a PHP script, but it appears that it is not updating the record in the database and I am not sure why and so would appreciate if you can share some insights.
Code
$query = "UPDATE DatTable SET DF_PARTY_ID = :party_id,
DF_PARTY_CODE = :party_code,
DF_CONNECTION_ID = :connection_id WHERE DF_PARTY_ID = ':party_id'";
$stmt = $this->connection->prepare($query);
$stmt->bindValue(':party_id', $data[0], PDO::PARAM_INT);
$stmt->bindValue(':party_code', $data[1], PDO::PARAM_INT);
$stmt->bindValue(':connection_id', $data[2], PDO::PARAM_INT);
$stmt->execute();
Inspiring solution leading to this approach. How can I fix this problem?
Might not help, but why are you only binding 3 variables, when there are 4? I can’t say that I have experience doing this in PHP, but in Perl and Oracle it would throw an error. I’d try binding the 2 SETs and the 1 WHERE, and removing the first assignment, and see if that works.