I want to update a table field by appending a new value ro the existing value.
if the field current value is 100
once updated with value 200
, it should be 100,200
.
I tried:
$this->db->set('return', 'CONCAT(return,',','.$loan_number.')', FALSE);
$this->db->where( 'id', $this->input->post('id') );
$this->db->update('tbl_test');
I think I'm using CONCAT in the wrong way though.
Any idea how to get this work?
You have a problem with you quotes. This code gives four parameters to $this->db->set()
: return
, CONCAT(return,
, ,'{loan_number}
and FALSE
. Your trying to append ,{loan_number}
to return right? If so then you should either escape you quotes ore use different quotes.
Escaping:
$this->db->set('return', 'CONCAT(return,\',\',\''.$loan_number.'\')', FALSE);
Different qutes:
$this->db->set('return', "CONCAT(return,',','".$loan_number."')", FALSE);