In CodeIgniter how to add string to fields?
$this->db->where('acctg_store_id',$data['acc_store_id']);
$this->db->set('dscr',dscr . $data['desc']);
$this->db->set('stat',$data['val_selected']);
$this->db->update('acctg_store',$db)
$this->db->where('acctg_store_id',$data['acc_store_id']);
dscr
is in text and in update, I want to add string to dscr
答案 0 :(得分:1)
我认为您希望通过使用旧值dscr
附加新值来更新字段dscr
。因此,您可以在dscr
$this->db->where('acctg_store_id',$data['acc_store_id']);
$res = $this->db->get("acctg_store");
$row = $res->row();
$dscr = $row->dscr;
然后在更新中附加此值$dscr
$this->db->where('acctg_store_id',$data['acc_store_id']);
$this->db->set('dscr', $dscr . "/". $data['desc']);
$this->db->set('stat',$data['val_selected']);
$this->db->update('acctg_store',$db)
答案 1 :(得分:0)
就这样做
$data = array(
'dscr' => $data['desc'],
'stat' => $data['val_selected'],
);
$this->db->where('acctg_store_id', $data['acc_store_id']);
$this->db->update('acctg_store', $data);
答案 2 :(得分:0)
试试这个
$this->db->where('acctg_store_id',$data['acc_store_id']);
$dscr="dscr" . $data['desc'];
$this->db->set('dscr',$dscr);
$this->db->set('stat',$data['val_selected']);
$this->db->update('acctg_store',$db);