When using mysqli::insert_id in PHP for INSERT INTO ON DUPLICATE KEY UPDATE, I keep getting the next auto increment rather than the updated row if the row is updated. In the same database but in another table, I don't have this behavior when using ON DUPLICATE KEY UPDATE. Instead, I get the id of the updated row. But now for some reason in a new table I have created, I keep getting the next id that doesn't even exist. Both tables are MyISAM, and have an auto increment field. I don't understand why they behave differently.
Example:
==================================
Table: example
==================================
id | unique_field | data
==================================
1 | unique1 | 123
2 | unique2 | 456
INSERT INTO
example
SET
unique_field = 'unique1',
data = '321'
ON DUPLICATE KEY UPDATE
data = '321'
// mysqli::insert_id returns 3 (not 1)!!
Any ideas?