Update multiple Rows in Codeigniter

前端 未结 3 1064
闹比i
闹比i 2020-12-16 20:41

I have been looking around but I have not found an answer yet. Kindly help if you know the answer.

How do you update multiple rows in CI?

In my MySQL:

<
3条回答
  •  甜味超标
    2020-12-16 20:55

    Here is a simple php code for perform this operations.

    load->database();
    $data = array(
    'ID' => 1,
    'Settings Name' => 'Hello',
    'Settings Value' => 'True'  
    );
    $this->db->where('ID', '1');
    $this->db->update('', $data);
    $data1 = array(
        'ID' => 2,
        'Settings Name' => 'World',
        'Settings Value' => 'Good'
        );
        $this->db->where('ID', '2');
        $this->db->update('
    ', $data1); }

    In $this->db->where('ID', '1'); ID is your table field and 1 is the value. In array first parameter will contain the table name, the second parameter is an associative array of values

    提交回复
    热议问题