This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-13. For the latest, interactive version please visit https://mariadb.com/kb/.

mysql_stmt_affected_rows

Syntax

my_ulonglong mysql_stmt_affected_rows(MYSQL_STMT * stmt);

Description

Returns the number of affected rows by the last prepared statement associated with mysql, if the operation was an "upsert" (INSERT, UPDATE, DELETE or REPLACE) statement, or -1 if the last prepared statement 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_stmt_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.

See Also

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.