简体   繁体   中英

update new data but do not remove previous data table in codeigniter

This is my table

----------
id     | user_id  | sid  | fid  | channel




----------
1     | 10usl1 | 1029298 | null | snapdeal  

i have update fid and channel flipkart then channel field remove the snapdeal but i want snapdeal,flipkart

update query do not remove snapdeal for channel field please help me

This my code

public function set_response_data($id,$data){       
        $whereCondtions = array(
               'user_id' =>$this->user_id,
               'id' => $id);
        $this->db->where($whereCondtions);
        $this->db->update($this->table, $data);
        return $id;}

Sql query For your question

UPDATE tbl_name SET `channel` = CONCAT($data['val'], ' , ',channel), `fid` = $data['fid'] WHERE $whereCondtions;

IN codeigniter You just send channel value in concat form...

Like $data['val'] = CONCAT('snapdeal', ' , ',channel)

Concat function use for concatenate two string in mysql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM