When executing an SQL statement, such as
INSERT INTO table
... ON DUPLICATE KEY UPDATE ...
I rely on mysql_affected_rows() to determine if an insert or an update was performed.
as the mysql site on http://dev.mysql.com/doc/refman/5.1/en/mysql-affected-rows.html , it states:
For INSERT ... ON DUPLICATE KEY UPDATE statements, the affected-rows value is 1 if the row is inserted as a new row and 2 if an existing row is updated.
All was working Ok until we upgraded to MySQL 5.1.16, when many queries now had mysql_affected_rows() returning MINUS ONE (-1)
The suggested solution on the MySQL site on http://dev.mysql.com/doc/refman/5.1/en/mysql-store-result.html is to call the function mysql_store_result() after each execution of the function mysql_query() on a select query.
However, PHP does not seem to have such a function defined.
How do I get mysql_affected_rows() to work correctly using PHP and MySQL 5.1.16?