PHP: Number of rows actually changed after mssql UPDATE query
In PHP, mysql_affected_rows() tells me how many rows in a table where changed after a MySQL UPDATE statement. It only counts rows where values actually changed.
The MSSQL 开发者_C百科equivalent, mssql_rows_affected(), however, returns the number of rows where the WHERE clause of the UPDATE statement is true, even if nothing in those rows actually changes.
Is there a way to determine the number of rows that were actually changed in MSSQL?
You can add a clause to your WHERE condition to not update a row if it doesn't change:
UPDATE yourtable
SET foo = 'bar'
WHERE yourcondition
AND foo <> bar
You can use mysql_affected_rows
int mysql_affected_rows ([ resource $link_identifier ] )
More information at : http://php.net/manual/en/function.mysql-affected-rows.php
精彩评论