如何在插入新字段时更改数据库中的现有数据
这是我的代码
$sql = array(
'company_id' => $this->company_id,
'template_name' => $temp_name,
'temp_default' => $temp_default,
'region_name' => $region_name,
'division_name' => $division_name,
'division_address' => $division_address,
'document_title' => $document_title,
'division_logo' => $division_logo,
'deped_logo' => $deped_logo,
'created_date' => date("Y-m-d H:i:s"),
'created_by_account_id' => $this->account_id
);
$sql1 = array(
'temp_default' => 'No'
);
if($temp_default == 'Yes'){
$f = $this->dsm->default_temp($this->company_id,"Yes");
print_r($f->template_id);
$this->db->where('template_id',$f->template_id);
$this->db->set('temp_default', 'No', FALSE);
$this->db->update('template',$sql1);
$this->db->insert('template',$sql);
echo json_encode(array(
"success" => true
));
}
else{
$this->db->insert('template',$sql);
echo json_encode(array(
"success" => true
));
}
我可以插入新字段,但其他字段未更新/更改。