INSERT Batch, and if duplicate key Update in codeigniter
You will have to go with little custom query by adding "ON DUPLICATE" statement
$sql = $this->db->insert_string('YourTable', $data) . ' ON DUPLICATE KEY UPDATE duplicate=duplicate+1';
$this->db->query($sql);
$id = $this->db->insert_id();
Also please check this out, it will give you better solution