Home > Database > Mysql Tutorial > How to Check if a MySQL DELETE Operation Was Successful?

How to Check if a MySQL DELETE Operation Was Successful?

DDD
Release: 2024-10-29 21:14:29
Original
688 people have browsed it

How to Check if a MySQL DELETE Operation Was Successful?

How to Determine the Success of a MySQL DELETE Operation

When executing a DELETE statement in MySQL using PHP, determining its success can prove beneficial.

Using MySQL Query Functions

To ascertain the outcome of a DELETE operation using mysql_query, the function returns:

  • TRUE: Operation succeeded.
  • FALSE: Operation failed due to an error.

Alternatively, when employing PDO::exec, the function returns:

  • Number of rows modified or deleted: Positive integer indicating success.
  • 0: No rows were affected.

mysql_affected_rows Function

To verify the impact of a DELETE operation more precisely, consider using the mysql_affected_rows function. This function returns:

  • Number of rows affected: Positive integer indicating the number of rows deleted.
  • 0: No rows were deleted.

The above is the detailed content of How to Check if a MySQL DELETE Operation Was Successful?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template