I begin by adding data to table events
, field exceptions
like this
function events_exceptions($rec_id, $evt_id)
{
//$evt_id = 1;
$this->db->where('record_id', $rec_id);
$this->db->update('events', array('exceptions' => $evt_id));
}
This will give me
exceptions
1
If I run this again with $evt_id = 2
I'll get
exceptions
2
and so on.
I want to actually append the new data to that field instead of update, so I would have (note the comma)
exceptions
1,2,3 //etc
I think this can be done by making a call to DB, reading the content of the row/field, and concatenating via PHP - then updating the record. But I wanted to avoid such overhead.
Is there a way of doing this via MySQL CONCAT
?
Thanks for your help.
$query = "UPDATE table1 SET field1 = CONCAT(ifnull(field1,''),'$extra') WHERE id = '$id'";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With