PHP - MYSQL:从xml文件更新mysql

I need to enter data into a mysql database from an xml file. I have no problem with regard to entering and updating data.

my problem is with the deletion of data in the database when no longer exists in the xml file.

how do I know which data do not exist anymore in the xml file and delete them in the db?

Thanks!

if you have a common identifier, exists in both XML and db, it's a piece of cake:

  1. read all the identifiers from the table into array
  2. read XML records one by one and update rows in a db, deleting successfully updated identifiers from the array
  3. delete records that remained in array

Either:

  1. Load the data into a temp table
  2. Delete from the live table where the data does not exist in the temp table
  3. Add new records from the temp table into the live table
  4. update live table from the temp table

Or: use a field in the table to flag that a row has been modified from the data in the xml file.

  1. set the field to false for all rows before the import
  2. set the field to true when you add or update rows from the xml
  3. delete all the false rows