Forum Moderators: open

Message Too Old, No Replies

MySQL Import

         

multiz

9:32 pm on Jun 8, 2007 (gmt 0)

10+ Year Member



I'm a little new to MySQL -- so, help is very much appreciated.

Does anyone know how I could import every item from an XML feed into a MySQL table and then have the items automatically delete after 24 hours, and if I imported another XML feed, it wouldn't replace the existing items but add to it (and wouldn't add duplicates)?

I would like to do all of this with PHP.

Thanks if you can help or point me the correct direction.

physics

9:59 pm on Jun 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is definitely possible with a PHP script. Here are the steps you'd take.

Set up a cron job (crontab -e on linux) or use the windows scheduler.

Using PHP/MySQL, delete any existing items older than 24 hours.
[us2.php.net...]

Parse the XML with PHP:
[us2.php.net...]

Insert new data into MySQL (first check if each item exists, if it does then do not insert).

Have your scheduler run this at least every 24 hours to remove old items.