Připojí se k poli tabulky t_franchise_price
spíše než přepsat.
Změnit:
$this - > franchise_price_model - > batchTestupdate($postData);
Komu:
$this->franchise_price_model->batchTestupdate($postData, 2);
Změňte metodu modelu na tuto:
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";
}
}
}
}