I'm new to PHP and mysql, and I wonder if there is a way to use the result after a DELETE query.
For example:
$stmt = $mysqli->prepare("DELETE FROM users WHERE id=?");
$stmt->bind_param('i', $someID);
$stmt->execute();
//Here I want to use the name of the deleted user.
I know I can make a SELECT query before deleting, I just wonder if there is a smart way to get the deleted row. All I found so far is
$stmt->affected_rows
but that only gives the number of affected rows.
Thanks
A DELETE
query deletes the data. It does not fetch the data. In fact, afterwards there's no data to fetch since it's been deleted. There is no "result" of a DELETE
query.
SELECT
the data before deleting if you need it.