开发者

Zend DB: How to find the actual amount of affected rows with INSERT ON DUPLICATE KEY?

开发者 https://www.devze.com 2022-12-22 06:14 出处:网络
$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:

$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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号