Jump to content


Photo

Validate MySQL DELETE


  • Please log in to reply
1 reply to this topic

#1 bmarinho

bmarinho
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 11 September 2006 - 04:58 PM

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



#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 11 September 2006 - 05:13 PM

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.

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users