note 102523 added to mysqli.affected-rows

[email protected] Fri, 18 Feb 2011 14:50:25 -0800
Newsgroups php.notes
Message-ID <[email protected]>
On "INSERT INTO ON DUPLICATE KEY UPDATE" queries, though one may expect affected_rows to return only 0 or 1 per row on successful queries, it may in fact return 2.

From Mysql manual: "With ON DUPLICATE KEY UPDATE, the affected-rows value per row is 1 if the row is inserted as a new row and 2 if an existing row is updated."

See: http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

Here's the sum breakdown _per row_:
+0: a row wasn't updated or inserted (likely because the row already existed, but no field values were actually changed during the UPDATE)
+1: a row was inserted
+2: a row was updated
----
Server IP: 69.147.83.197
Probable Submitter: 65.36.73.107
----
Manual Page -- http://www.php.net/manual/en/mysqli.affected-rows.php
Edit        -- https://master.php.net/note/edit/102523
Del: integrated  -- https://master.php.net/note/delete/102523/integrated
Del: useless     -- https://master.php.net/note/delete/102523/useless
Del: bad code    -- https://master.php.net/note/delete/102523/bad+code
Del: spam        -- https://master.php.net/note/delete/102523/spam
Del: non-english -- https://master.php.net/note/delete/102523/non-english
Del: in docs     -- https://master.php.net/note/delete/102523/in+docs
Del: other reasons-- https://master.php.net/note/delete/102523
Reject      -- https://master.php.net/note/reject/102523
Search      -- https://master.php.net/manage/user-notes.php