Jump to content

Archived

This topic is now archived and is closed to further replies.

bmarinho

Validate MySQL DELETE

Recommended Posts

Hi all,

I got an issue in the week and i'm trying get some help to solve him.

Well, the question is:

I have a group of records in a table and the user need to pick some of them to be removed from de database. Some of the records cannot be removed cause they are required from other tables (FK's), so i need to validate them. I have autocommit on in the database configuration, but i tried do set him off just to use the "affected_rows" property after a DELETE and getting the number of rows affected. It keeps me returning null after the DELETE.

How can i solve this question? If not what is the alternative?

Thank you for the help.

Bruno Marinho

Share this post


Link to post
Share on other sites
The easiest thing to do would be to setup a counter and check the result of the mysql_query() call as a indicator of whether a specific row was deleted.  That would only work if you're deleting them one at a time.  If you're deleting more than one at a time and "affected_rows" doesn't work, you could run a COUNT(*) query on the table before and after.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.