1

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 :)

Community
  • 1
  • 1
black_belt
  • 6,601
  • 36
  • 121
  • 185

1 Answers1

1

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.

Sergey Tsibel
  • 1,595
  • 1
  • 18
  • 31