Users table
Id Name Email
1 Mike mike@gmail.com
2 John john@gmail.com
Running UPDATE query with php Mysqli
$sql = "UPDATE users SET email=? WHERE id=?";
$stmt= $conn->prepare($sql);
$stmt->bind_param("si", $name, $id);
$stmt->execute();
$rowsEffected = $stmt->affected_rows;
Scenario1:
UPDATE users SET email='mike@gmail.com' WHERE id=1"
The above scenario returns $rowsEffected as zero as the data is same as before.
Scenario 2:
UPDATE users SET email='tyson@gmail.com' WHERE id=1"
The above scenario returns $rowsEffected as one as the data is not same as before.
Scenario 2:
UPDATE users SET email='eric@gmail.com' WHERE id=100"
The above scenario returns $rowsEffected as zero as the Id does not exists.
Here in the above scenarios, how to determine whether the update has been successful or not. How to differentiate between scenarios 1 , 2 with 3. I meant how to can we test whether an invalid update request with Id happens.