On 15-10-08 04:45 PM, Ashley Sheridan wrote:
Hi All,
This is a bit of an odd one, and while it's largely an SQL problem, it
will have PHP logic because SQL just doesn't have quite the syntax.
I'm sure this is a standard problem that has a standard solution, but as
of yet, I've not come across said solution.
I need to update a series of data in a DB. Some of it may exist already,
and some may need to be removed.
Now the typical for updating (but not removing) data and adding new is
the familiar:
INSERT ... ON DUPLICATE KEY UPDATE ...
syntax, but what about those bits which might need removing?
What's the typical solution that any of you use? I normally just empty
all rows of data sharing the common id for the set of data and then
insert new rows, but that seems wasteful to me, and less clean than it
ought to be.
A very common solution is to not actually delete.
Rather have a 'status' column that is set to active or deleted. Then a
delete becomes just another form up update.
--
Stephen
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php