Mahfuzur Rahman
Mahfuzur Rahman

Reputation: 1545

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(...)

Upvotes: 2

Views: 3393

Answers (1)

Shafiqul Islam
Shafiqul Islam

Reputation: 5690

Try this but not tested

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

Upvotes: 5

Related Questions