Reputation: 6799
Could you please tell me how should I use ON DUPLICATE KEY UPDATE in codeigniter's way? I have found this similar question here How would I use ON DUPLICATE KEY UPDATE in my CodeIgniter model?. But couldn't find the exact answer.
I have tried the following but its not working
$this->db->on_duplicate_update('id');
$this->db->insert('voucher', $data);
Thanks :)
Upvotes: 1
Views: 5604
Reputation: 1625
There is a difference between on_duplicate()
and insert()
.
Whenever I'm parsing the file with some data and I want all duplicates rows from the new file be updated over the old rows( with no duplicates) and insert new rows - use on_duplicate()
with unique index on table
If there is no need to update the old rows (duplicates), use insert()
instead.
Upvotes: 1