Warning This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0.
This function returns the number of deleted records plus the number of inserted records. ON DUPLICATE KEY UPDATE" queries, the return value will be I see that when try to use mysql_affected_rows() with "mysql_pconnect(...)" without link indetifier as param in "mysql_affected_rows()" the result is allways -1.
When use link identifier "mysql_affected_rows($this_sql_connection)" - everything is Fine.
This is is on PHP Version 5.2.0Hope that this was helpfull for somebody If you use "INSERT INTO ...
ON DUPLICATE KEY UPDATE" syntax, mysql_affected_rows() will return you 2 if the UPDATE was made (just as it does with the "REPLACE INTO" syntax) and 1 if the INSERT was. You have table t2 linked to table t1 by a CASCADE ON DELETE foreign key.3.
So if you use one SQL request to insert several rows at a time, and some are inserted, some are just updated, you won't get the real count. t2 has a UNIQUE key so that duplicate records are unacceptable.3.
You have a REPLACE query on t1 followed by an INSERT query on t2 and expect the second query to fail if there's an attempted insert of a duplicate record.PROBLEMYou notice that the second query is not failing as you had expected even though the record being inserted is an exact duplicate of a record previously inserted.If the last query was a DELETE query with no WHERE clause, all of the records will have been deleted from the table but this function will return zero with My SQL versions prior to 4.1.2.When using UPDATE, My SQL will not update columns where the new value is the same as the old value.This creates the possibility that may not actually equal the number of rows matched, only the number of rows that were literally affected by the query.The REPLACE statement first deletes the record with the same primary key and then inserts the new record.