Actually my code was like that
if (!$country_id) { $this->db->insert('country_master', $insert_array); $id = $this->db->insert_id(); } else { $this->db->update('country_master', $insert_array, array("country_id" => $country_id, "last_updated" => $time)); } $afftectedRows = $this->db->affected_rows();
And I changed it to
if (!$country_id) { $this->db->insert('country_master', $insert_array); $id = $this->db->insert_id(); } else { $this->db->update('country_master', $insert_array, array("country_id" => $country_id, "last_updated" => $time)); $afftectedRows = $this->db->affected_rows(); }
And now it works great.
And thanks for the answers.
source share