changing database inserts to update duplicates

http://stackoverflow.com/questions/548541/insert-ignore-vs-insert-on-dup
licate-key-update