Update and delete with a row count
rowCount() tells you how many rows changed, so you can answer "not found" properly.
PHP · Update and delete with a row countIntermediate
$st = $pdo->prepare('UPDATE users SET name = ? WHERE id = ?');
$st->execute(['Ali Khan', 1]);
if ($st->rowCount() === 0) {
echo 'No change (user missing or same name)';
}
$st = $pdo->prepare('DELETE FROM users WHERE id = ?');
$st->execute([2]);
echo $st->rowCount() . ' row(s) deleted';pdoupdatedelete