mysql_affected_rows([link_identifier])

Description: Returns (as an integer) the number of rows affected in the last MySQL operation that modified data (such as an INSERT, UPDATE, or DELETE).

If link_identifier is specified (referring to a database connection), it refers to a query made with that database connection. If not specified, it refers to the last link opened with a mysql_connect().

Notes:

  • If an UPDATE is performed by the query, and it matches rows (therefore writing data) but without actually changing values in those rows, these rows are not counted in the value returned by mysql_affected_rows(); only those rows where data is actually changed are counted.

  • The function returns -1 if an error occurs in the query.

  • It returns 0 if the query ...

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.