Is it possible to do an active record query in CodeIgniter that will update an existing record if one already exists or insert if it doesnt, for the given k
Updated Milaza's answer - Simply done
$updt_str = ''; foreach ($array as $k => $v) { $updt_str = $updt_str.' '.$k.' = '.$v.','; } $updt_str = substr_replace($updt_str,";", -1); $this->db->query($this->db->insert_string('table_name', $array).' ON DUPLICATE KEY UPDATE '.$updt_str);