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 update has been performed. as the mysql site at http://dev.mysql.com/doc/refman/5.1/en/mysql-affected-rows.html , it reports:
For INSERT ... ON DUPLICATE KEY UPDATE statements, the value of the affected rows is 1 if the row is inserted in a new row and 2 if the existing row is updated.
Everything worked fine until we upgraded to MySQL 5.1.16, when many queries now had mysql_affected_rows () returning MINUS ONE (-1)
The proposed solution on the MySQL website at http://dev.mysql.com/doc/refman/5.1/en/mysql-store-result.html should call the mysql_store_result () function after each execution of the mysql_query () function to request a choice.
However, PHP does not have such a function.
How can I get mysql_affected_rows () to work correctly with PHP and MySQL 5.1.16?
source
share