You are here:  » Magic Parser and mySQL database


Magic Parser and mySQL database

Submitted by formmailer on Sun, 2009-01-25 08:19 in

Hi David,

I am currently trying to put feeds into an mySQL database and Magic Parser does the trick very well.
The only problem is: right now I am simply deleting all existing feed records from the database and after this, I add the complete feed.
This works, but I'd actually I'd like to change only the updated records that have been changed. Since the products have a product ID, this can be done quite easily.
My problem, however, is when a product gets removed from the feed. How can I figure out it has been deleted and delete it from my database.

Any ideas?

/Jasper

Submitted by support on Sun, 2009-01-25 13:20

Hi Jasper,

The trick here is to add a "deleteme" field of type INT to your table. Before import; set deleteme=1 in all records using something like:

UPDATE mytable SET deleteme=1

Then, perform your update, and as you update each record, set deleteme back to 0. Finally, after running import, you can remove expired records using:

DELETE FROM mytable WHERE deleteme=1

Hope this helps!
Cheers,
David.

Submitted by formmailer on Sun, 2009-01-25 20:02

Great trick, it works like a charm!
Thanks David!

/Jasper