Hello everyone.
This is my first post here. 🙂
I'm implementing a very simple PHP class (learning purposes only) for doing CRUD tasks and I would love to receive some tips/advices about good practices.
As every CRUD class, this one has a delete() method which is used only to delete an entry from the database (MySQL in my case).
My question is:
For the delete() method, is it good to check if the entries that match the WHERE clause really exist before effectively deleting them?
In other words: before executing the deletion itself, should I include as part of the code for the delete() method the instructions for checking if the entries really exist or this checking should be done outside elsewhere (maybe in an isolated method)? Or yet, do you guys think that shouldn't be a concern, since the DBMS doesn't complain (i.e. doesn't emit any errors) when deleting entries that don't exist in the given table?
What is the best option? Which approach the PHP frameworks use for handling this situation?
Thanks a lot for any help! 🙂