I have this PDO statement that doesn't update my database and doesn't return any error:
// $database = initialized PDO instance
$status = 'processing';
$submission_id = 213;
$sql = "UPDATE `submission`
SET `status`=':status'
WHERE `id`=':submission_id'";
$query = $database->prepare($sql);
$result = $query->execute(array(
':status' => $status,
':submission_id' => $submission_id
));
var_dump($result); // true
var_dump($query->rowCount()); // 0
$database->errorCode(); // 0000
$database->errorInfo(); // [0]=> string(5) "00000" [1]=> NULL [2]=> NULL
If I remove parameters from $sql it works:
$sql2 = "UPDATE `submission` SET `status`='processing' WHERE `id`='214'";
all results are the same except $query->rowCount()
which returns 1 this time and the database is updated. I use the same PDO object for other insert and select operations and it works well.
Why the first parametized query doesn't work?