Jump to content

Validate MySQL DELETE


bmarinho

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

Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.