Si aggiunge al campo della tabella t_franchise_price
anziché sovrascrivere.
Modifica:
$this - > franchise_price_model - > batchTestupdate($postData);
A:
$this->franchise_price_model->batchTestupdate($postData, 2);
Cambia il metodo del tuo modello in questo:
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";
}
}
}
}