$data = array(
'title' => $title,
'name' => $name,
'date' => $date
);
$this->db->where('id', $id);
$this->db->update('mytable', $data);
$this->db->where('user_id',$id);
$q = $this->db->get('profile');
if ( $q->num_rows() > 0 )
{
$this->db->where('user_id',$id);
$this->db->update('profile',$data);
} else {
$this->db->set('user_id', $id);
$this->db->insert('profile',$data);
}
$this->db->set('fieldname', 'value');
$this->db->where('id', 2);
$this->db->update('tablename');