Parâmetros

Valor Retornado

An integer greater than zero indicates the number of rows affected or
retrieved.
Zero indicates that no records where updated for an UPDATE/DELETE
statement, no rows matched the WHERE clause in the query or that no query
has yet been executed. -1 indicates that the query has returned an error.
NULL indicates an invalid argument was supplied to the function.

Nota:

If the number of affected rows is greater than maximal PHP int value, the
number of affected rows will be returned as a string value.

User Contributed Notes 3 notes

It appears that an UPDATE prepared statement which contains the same data as that already in the database returns 0 for affected_rows. I was expecting it to return 1, but it must be comparing the input values with the existing values and determining that no UPDATE has occurred.

I'm not sure whether or not this is the intended behavior, but I noticed through testing that if you were to use transactions and prepared statements together and you added a single record to a database using a prepared statement, but later rolled it back, mysqli_stmt_affected_rows will still return 1.