You are here: Re: How to delete a record in a one to many situation when using a list in form « PHP Programming Language « IT news, forums, messages
Re: How to delete a record in a one to many situation when using a list in form

Posted by ImOk on 12/18/60 11:48

Easiest way is to delete and then insert. But you should do it one
record at a time. You dont want to delete all at once and then insert.
Otherwise if you have a system crash right after the delete you could
lose massive amounts of data instead of just one record.

To do this you need to add a new character type 'delete' flag column in
your items table which would be used for this purpose.

1) Update all the records you want to delete by putting in X in the
deleteFlag.
..
2) Delete the first one whose key matches the one you are inserting
from the list.

3) Insert the new one from the list (leave the deleteFlag column null
or put a blank)

Repeat the 1-3 process until you've inserted all your records from the
list.

4) Now delete all the records that still have an X in the delete flag
column. These would be the left over records.

You can also use Transactions but its only safe as long as your server
will not crash during commit.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация