(PHP 4, PHP 5) mysql_affected_rows — Get number of affected rows in previous MySQL operation Descriptionmysql_affected_rows(resource Parameterslink_identifier The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() had been called with no arguments. If no connection is found or established,
an Return ValuesReturns the number of affected rows on success, and -1 if the last query failed. If the last query was a DELETE query with no WHERE clause, all of the records will have been deleted from the table but this function will return zero with MySQL versions prior to 4.1.2. When using UPDATE, MySQL 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 plus the number of inserted records. In the case of "INSERT ... ON DUPLICATE
KEY UPDATE" queries, the return value will be ExamplesExample #1 mysql_affected_rows() example
The above example will output something similar to: Records deleted: 10 Records deleted: 0 Example #2 mysql_affected_rows() example using transactions
The above example will output something similar to: Notes
See Also
HMax ¶ 15 years ago
Ome Ko ¶ 11 years ago
deponti A_T tiscalinet D0T it ¶ 18 years ago
vitospericolato at gmail dot com ¶ 5 years ago
dobrys at abv dot bg ¶ 15 years ago
temp02 at flexis dot com dot br ¶ 17 years ago
ahmd ¶ 6 years ago
brian at smitherconsulting dot com ¶ 5 years ago
steffen at showsource dot dk ¶ 18 years ago
gtisza at gmail dot com ¶ 3 years ago
sean at adtools dot co dot uk ¶ 14 years ago
$action==1){
|