我想插入从excel导入的数据
我有2个数据条目,但它只插入一个 这是我的Excel数据 pictures 这是我的代码
$objReader= PHPExcel_IOFactory::createReader('Excel2007'); // For excel 2007
//Set to read only
$objReader->setReadDataOnly(true);
//Load excel file
$objPHPExcel=$objReader->load(FCPATH.'media/export_redeem/'.$file_name);
$allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$arrayCount = count($allDataInSheet);
for($i=2;$i<=$arrayCount;$i++)
{
$product_id= $allDataInSheet[$i]["A"];
$email= $allDataInSheet[$i]["B"]; //Excel Column 1
$voucher= $allDataInSheet[$i]["C"]; //Excel Column 2
$date=$allDataInSheet[$i]["D"]; //Excel Column 3
$last = $this->db->where('member_email',$email)
->get('member')
->row('member_id');
$input=array(
'product_id'=>$product_id,
'member_email'=>$email ,
'member_id'=>$last ,
'voucher_code'=>$voucher ,
'created_date'=>$date ,
'status'=>"1",
// 'created_date' =>date("Y-m-d H:i:s"),
'deleted' => "0"
);
$this->global_model->save_data($input,"redeem_product");
redirect("admin_redeem_transaction");
}
这是我的模特
function save_data($data, $table){
$return = FALSE;
if ($this->db->insert($table, $data)){
$return = TRUE;
}
return $return;
}
请帮忙,抱歉我的英文