Tilføjes i tabelfeltet t_franchise_price
i stedet for at overskrive.
Skift:
$this - > franchise_price_model - > batchTestupdate($postData);
Til:
$this->franchise_price_model->batchTestupdate($postData, 2);
Skift din modelmetode til denne:
public function batchTestupdate($data = [], $method=1){
$db_table = $this->db->dbprefix($this->table_test);
$sql = "";
if($method == 1){
$this->db->update_batch($this->table_test, $data , 'test_id');
}
else if($method == 2){
foreach($data as $k=>$v){
$sql = "UPDATE $db_table SET t_franchise_price = TRIM(BOTH ',' FROM CONCAT(COALESCE(t_franchise_price,''), ',', ?)) WHERE test_id = ?;";
$result = $this->db->query($sql, array($v['t_franchise_price'], $v['test_id']));
if($result === false) {
echo "ERROR at index $k - query: ((".$this->db->last_query()."))<br/><br/>\n\n";
print_r($this->db->error()); echo "<br/><br/>\n\n";
}
}
}
}