Zend DB: How to find the actual amount of affected rows with INSERT ON DUPLICATE KEY?
$db->update() returns the affected amount of rows.
There is no Zend_DB method for insert ... on duplicate key update ..., so one should use the query() method:
$result = $db->query('INSERT INTO table(key, field) SELECT val1, val2 FROM table as t2 ON DUPLICATE KEY UPDATE field = VALUES(field)');
To find out the am开发者_StackOverflow中文版ount of affected or inserted records: $result->rowCount()
But this method also counts all the records that were updated with the same value.
I need to know all of the actual affected (changed) records.
Thanks!
Unfortunately the "On Duplicate Key Update" causes ROW_COUNT() or mysql_rows_affected() to report rows with multiple updates, it is not a count of UNIQUE rows that are updated.
精彩评论