Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
06-30-2010, 11:30 PM #1
- Join Date
- Jun 2008
- Thanked 12 Times in 12 Posts
help to update db record if record data has changed from last time?
I Have an script which inserts records into my db and this script is run every hour to keep everything up to date, i then have an rss feed which posts the latest items to twitter/facebook etc which works fine.
the problem im having is that if a record is being added to my db table which is already in there but it has a field which has changed from the last time it was inserted how do i overwrite the data in that field
for example here is my code
$insert_codes = "INSERT INTO
codes (codeID, codeLink, storeID, details, datestamp, expireDate)
VALUES ('$sCode', '$sUrl', '$iId2', '$sDescription', '$date', '$sEndDate') ON DUPLICATE KEY UPDATE expiredate='$sEndDate' details='$sDescription'";
hope this makes sence?
any help is appreciated
07-01-2010, 03:22 AM #2
- Join Date
- Jul 2005
- New York, NY
- Thanked 19 Times in 19 Posts
Create an additional column in your table call hash. Take the raw RSS data for each record and do a sha1 or md5 hash (sha1 is preferable due to the lower number of potential collisions) and store that in the record with the rest of the data. Every time you pull data from the RSS, you can do the same hash and check to see if the hash values are different. If they are, you can do an update.