Results 1 to 4 of 4

Thread: Delete if present

  1. #1
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default Delete if present

    How can I determine if a record has been deleted without running a select query first?

    Code:
    delete from `markers` where id = n
    Last edited by bluewalrus; 07-20-2011 at 04:31 AM.
    Corrections to my coding/thoughts welcome.

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    use mysql_affected_rows() afterwards (1 means it was deleted, 0 means it wasn't (for whatever reason - didn't exist, mysql error, etc.)).

  3. The Following User Says Thank You to traq For This Useful Post:

    bluewalrus (07-20-2011)

  4. #3
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Nice, thanks wasn't aware of that function. I should probably go through the available mysql functions.
    Corrections to my coding/thoughts welcome.

  5. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •