May 2005
Intermediate to advanced
352 pages
14h 39m
English
mysql_affected_rows( )
my_ulonglong mysql_affected_rows(MYSQL *mysql)
This returns the number of rows affected
by the most recent query for the current session. This function is
meaningful only for INSERT,
UPDATE, and DELETE statements.
For SQL statements that don't affect rows (e.g.,
SELECT), this function will return 0. For errors,
it will return -1.
...
mysql_query(mysql,"UPDATE workreq
SET tech_person_id = '1015'
WHERE tech_person_id = '1012'");
my_ulonglong chg = mysql_affected_rows(mysql);
printf("Number of requests reassigned: %ul \n", chg);
...In this example, an
UPDATE statement is issued and the number of rows
changed is extracted with the function and stored in the
chg variable, which is then printed. For
REPLACE statements, rows that are replaced are
counted twice: once for the deletion and once for the insertion.
Read now
Unlock full access