Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter Can';t将Excel中的所有数据输入数据库_Excel_Database_Codeigniter_Insert_Import From Excel - Fatal编程技术网

Codeigniter Can';t将Excel中的所有数据输入数据库

Codeigniter Can';t将Excel中的所有数据输入数据库,excel,database,codeigniter,insert,import-from-excel,Excel,Database,Codeigniter,Insert,Import From Excel,我想插入从excel导入的数据 我有两个数据项,但它只插入一个 这是我的excel数据 这是我的密码 $objReader= PHPExcel_IOFactory::createReader('Excel2007'); // For excel 2007 //Set to read only $objReader->setReadDataOnly(true); //Load excel file $objPH

我想插入从excel导入的数据

我有两个数据项,但它只插入一个 这是我的excel数据 这是我的密码

      $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");

            }

请帮助,对不起我的英语

您可以使用多行插入,如:@AjeetKumar,非常感谢您解决了问题?重定向(“管理兑换交易”);请将重定向代码移出for循环,否则只会将一条记录插入DB。@AjeetKumar是的,它现在可以工作了。多谢各位
 function save_data($data, $table){
    $return = FALSE;
    if ($this->db->insert($table, $data)){
        $return = TRUE;
    }

    return $return;
}