A couple notes:
1. affected rows
In updating a record using PHP/MySQL where the data is not actually changed, PHP will return 0 rows affected. To get around this, there is a flag that can be set when establish the db connection. Details here:
http://www.php.net/manual/en/function.mysql-affected-rows.php#335092. MySQL 'INSERT ... ON DUPLICATE KEY UPDATE'
I wrote a function that does this the long way by trying to select the row then inserting or updating based on the result. This is probably much more efficient. Details here:
http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.htmlkeywords: php, mysql, insert, update, affected, rows, duplicate