For the complete documentation index, see llms.txt. This page is also available as Markdown.

mysql_affected_rows

mysql_affected_rows returns the number of rows affected by the last INSERT, UPDATE, DELETE, or REPLACE statement executed on a MariaDB Connector/C connection.

Syntax

my_ulonglong mysql_affected_rows(MYSQL * mysql);

Parameter

Description

Returns the number of affected rows by the last operation associated with MySQL, if the operation was an "upsert" (INSERT, UPDATE, DELETE or REPLACE) statement, or UINT64_MAX (0xffffffffffffffff) if the last query failed.

When using UPDATE, MariaDB will not update columns where the new value is the same as the old value. This creates the possibility that mysql_affected_rows 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. This function returns the number of deleted records in addition to the number of inserted records.

Return Value

Returns the number of affected rows or -1 on error.

See Also

spinner

Last updated

Was this helpful?