How to concat or append data to mysql records in php using Codeigniter

 Use the following code to concat data to existing records:

$this->db->where('userId',$id);
$this->db->set('keywords', 'CONCAT(keywords,\',\',\'' .$addNewKw. '\')', FALSE);
$this->db->update('myTable');

 Here  'keywords' is column name of MYSQL table
             '$addNewKw' is the data which you want to append


Previous
Next Post »
Related Posts Plugin for WordPress, Blogger...