Lägger till i tabellfältet t_franchise_price
istället för att skriva över.
Ändra:
$this - > franchise_price_model - > batchTestupdate($postData);
Till:
$this->franchise_price_model->batchTestupdate($postData, 2);
Ändra din modellmetod till detta:
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";
}
}
}
}