Expose MySQL affected row counts
This commit is contained in:
@@ -5,4 +5,5 @@ mysql_disconnect
|
||||
mysql_error
|
||||
mysql_escape
|
||||
mysql_insert_id
|
||||
mysql_affected_rows
|
||||
mysql_query
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
:sig
|
||||
u32 mysql_affected_rows(MySQL* m)
|
||||
|
||||
:params
|
||||
m : pointer to an active MySQL connection
|
||||
return value : number of rows changed by the most recent statement
|
||||
|
||||
:see
|
||||
>mysql
|
||||
mysql_query
|
||||
mysql_insert_id
|
||||
|
||||
:content
|
||||
Returns the number of rows changed by the most recent insert, update, or delete on the connection. A successful statement that returns rows, a rejected query, or a null connection returns `0` rather than retaining an earlier statement's count.
|
||||
|
||||
:example
|
||||
MySQL* db = mysql_connect();
|
||||
if(db != 0)
|
||||
{
|
||||
mysql_query(db, "update users set active=1 where active=0");
|
||||
print("rows updated: ", mysql_affected_rows(db), "\n");
|
||||
mysql_disconnect(db);
|
||||
}
|
||||
else print("(requires a reachable MySQL server)\n");
|
||||
@@ -9,6 +9,7 @@ return value : a list of rows returned from executing the query
|
||||
|
||||
:see
|
||||
>mysql
|
||||
mysql_affected_rows
|
||||
|
||||
:content
|
||||
Executes a MySQL query and returns the resulting data, if any.
|
||||
@@ -17,6 +18,8 @@ Executes a MySQL query and returns the resulting data, if any.
|
||||
|
||||
The result is returned as a `DValue`, which makes it easy to iterate through rows and read fields with the usual `DValue` accessors.
|
||||
|
||||
After an insert, update, or delete, use `mysql_affected_rows()` to inspect how many rows changed.
|
||||
|
||||
:example
|
||||
MySQL* db = mysql_connect();
|
||||
if(db != 0)
|
||||
|
||||
Reference in New Issue
Block a user