【发布时间】:2016-11-21 06:57:20
【问题描述】:
我正在尝试为批发商、经销商和客户插入一批行 注意:我使用“追加”来添加输入行,但它们带有相同的输入名称。 我正在尝试首先将其应用于批发,但没有发生 当我在我的批发输入列表中添加另一行时,它只需要一行(我的最后一行)输入,而我的另一行输入被丢弃。数组的 var_dump 揭示了这一点。
这是我的控制器文件
$range = $this->input->post('wrange1');
$usertype = $this->input->post('wusertype');
$uom = $this->input->post('wuom1');
$price = $this->input->post('wamount1'); //array of price
$vat = $this->input->post('wvat1');
var_dump($range);// i am getting only one output
$updateArray = [];
for($x = 0; $x < sizeof($price); $x++){
$updateArray[$x] = array(
'product_id'=> $id,
'range' => $range[$x],
'usertype' => $usertype[$x],
'uom' => $uom[$x],
'price' => $price[$x],
'vat' => $vat[$x]
);
}
$this->productmodel->updatepricinglist($updateArray);
这是我的模型文件:
public function updatepricinglist($updateArray) {
$this->db->insert_batch('product_pricing', $updateArray);
}
【问题讨论】:
标签: mysql codeigniter