You are here : cpp0mysql_affected_rows

mysql_affected_rows() - 0

mysql_affected_rows() may be called immediately after executing a statement with mysql_query() or mysql_real_query().

It returns the number of rows changed, deleted, or inserted by the last statement if it was an UPDATE, DELETE, or INSERT.

For SELECT statements, mysql_affected_rows() works like mysql_num_rows().


Syntax

my_ulonglong mysql_affected_rows(MYSQL *mysql)


Example

char *stmt = "UPDATE products SET cost=cost*1.25
              WHERE group=10";
mysql_query(&mysql,stmt);
printf("%ld products updated",
       (long) mysql_affected_rows(&mysql));


Output / Return Value

An integer greater than zero indicates the number of rows affected or retrieved.

Zero indicates that no records were updated for an UPDATE statement, no rows matched the WHERE clause in the query or that no query has yet been executed.

-1 indicates that the query returned an error or that, for a SELECT query,mysql_affected_rows() was called prior to calling mysql_store_result().


Limitations


Alternatives / See Also


Reference