I updated a row in database using PDO.
$stmt = $db->prepare("UPDATE product SET price=? WHERE seller=?");
$stmt->execute(array(456,"Apple"));
This didn't worked for me
$updated_id = $db->lastInsertId();
How can i get the id of that updated row.
Best you can do is use PDO::rowCount()
to get the number of rows affected. Remember, your update statement may not update only one, so, there is no way to just get a single id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With