How to Verify the Success of a MySQL DELETE Operation
When executing a DELETE query using MySQL, it's crucial to determine whether the operation was successful. This is particularly important when deleting specific records based on criteria.
mysql_query() Method:
For traditional MySQL interactions using mysql_query(), a successful DELETE operation returns a boolean value:
PDO::exec() Method:
With PHP Data Objects (PDO), PDO::exec() is used for DELETE statements. Unlike mysql_query(), PDO::exec() returns the number of affected rows:
Additional Tips:
The above is the detailed content of How Do I Verify the Success of a MySQL DELETE Operation?. For more information, please follow other related articles on the PHP Chinese website!