tags:

views:

304

answers:

1

$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 amount 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!

A: 

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.

J Jorgenson