Search code examples
phpmysqlcodeignitercodeigniter-3

How to update database column value with CONCAT() function using codeigniter?


Write now i'm using this query -

$this->db->query("UPDATE my_table SET member = CONCAT(member,',',$user_id) WHERE id=$id");

How I convert this query in Codeigniter style, like $this->db->update(...)


Solution

  • Try this but not tested

    $this->db->where('id',$id);
    $this->db->set('member', 'CONCAT(member,\',\',\''.$user_id.'\')', FALSE);
    $this->db->update('my_table');