我有一个类似这样的表:
VIN Color Tires Mileage
-------------------------------------
(car's VIN) red P235/70R15 32976
If I do body work and change the color, change the tires, or the mileage changes while testing a repair, I want to be able to keep all of the unchanged fields (color, tires) from the previous row while inserting the new row with the new mileage.
I need to keep the existing row.
How can I use PHP and MySQL to accomplish this?
You need to use a parent/child relationship. Here's an example with required columns to work:
ID parent_id VIN Color Tires Mileage
-------------------------------------------------------
1 NULL (car's vin) red P235/70R15 32976
2 1 '' blue P235/70R15 35017
请注意,您正在确定ID
2是ID
1的子级,并具有更新的信息。
您只需创建一个walker函数来拉取父和子之间的关系