I have a mySQL query using ON DUPLICATE KEY UPDATE that I am runnining from a PHP script. I would like to test whether an UPDATE or an INSERT occurred. How can I do that?
I have a mySQL query using ON DUPLICATE KEY UPDATE that I am runnining
Share
From MySQL documentation:
“With ON DUPLICATE KEY UPDATE, the affected-rows value per row is 1 if the row is inserted as a new row and 2 if an existing row is updated.”
You can use
mysql_affected_rows()to determine the number of rows affected.