dongxiequ3724 2016-08-08 09:58
浏览 36
已采纳

无法使用codeigniter一次插入超过100行

I am trying to insert more than 100 records at a time. if more records them form will not perform any action unless it will submit and redirect to another page.

How to sove this error.

I tried using insert_batch also. But no use. I changed php.ini post_max_size also,

Somebody please help me.

Below is my code for controller and model

controller code

foreach($chkproduct as $key=>$chkvalue1){

    foreach($chkvalue1 as $key1=>$chkvalue2 ) {


            $chkvalue=explode("/",$chkvalue2);
            $datachk['product_id']   =$chkvalue[0];
            $datachk['client_id']=$chkvalue[1];
            $ins1=$this->Sub_model->record_count_Product($chkvalue[0]);

            $num1=$ins1->num_rows();

            $qry1=$ins1->row();
            $prodId=$qry1->prod_rand_id;
            $datachk['payment_id']=$paymentid;
            $datachk['prod_rand_id']=$prodId;
            $datachk['sub_type']      =$st1[$chkvalue[0]][$key1];
        $datachk['prod_type']     =$pt1[$chkvalue[0]][$key1];
            $datachk['quantity']    =$qty1[$chkvalue[0]][$key1];

            $datachk['reductionamount'] =$redamount[$chkvalue[0]][$key1];
            $datachk['amountafterreduction'] =$ramount[$chkvalue[0]][$key1];
            $datachk['individual_amt'] =$ramount[$chkvalue[0]][$key1]+$redamount[$chkvalue[0]][$key1];
            $cliname=$clientname[$chkvalue[0]][$key1];
            //$date1=$sd1[$chkvalue];
            //$datachk['start_date']        = date('Y-m-d', strtotime($date1));
            $cliname=$clientname[$chkvalue[0]][$key1];

            $expper=explode("-",$per1[$chkvalue[0]][$key1]);
            //echo $expper[0];
            $smonth=$this->check($expper[0]);
            if($smonth>=10){
                $startyear=$year1[$chkvalue[0]][$key1]-1;
            }else{
                $startyear=$year1[$chkvalue[0]][$key1];
            }
            //echo $st1[$chkvalue];
            if($st1[$chkvalue[0]][$key1]==1){

                $endyear=$year1[$chkvalue[0]][$key1];

            }elseif($st1[$chkvalue[0]][$key1]==2){
                if($smonth>=02  && $smonth<=10){$endyear=$year1[$chkvalue[0]][$key1]+1;}else{$endyear=$year1[$chkvalue[0]][$key1];}
            }elseif($st1[$chkvalue[0]][$key1]==3){
                if($smonth>=02  && $smonth<=10){$endyear=$year1[$chkvalue[0]][$key1]+3;}else{$endyear=$year1[$chkvalue[0]][$key1]+2;}
            }
            //echo $endyear;
            if($smonth==01){$endmonth=12;}else{$endmonth=$smonth-01;}
            $ts = strtotime($expper[0]."".$startyear);
            $lastdate=date('t', $endmonth); 
            if($endmonth=='02'){
                if($endyear%4==0){
                    $lastdate1=29;
                }else{
                    $lastdate1=28;
                }
            }
            elseif($endmonth=='04'  || $endmonth=='06' || $endmonth=='09' || $endmonth=='11'){
                $lastdate1=30;
            }else{
                $lastdate1=31;
            }
            //if($endmonth=='02'){$lastdate1=$lastdate-2;}elseif($endmonth%2==1){$lastdate1=30;}else{$lastdate1=31;}
            $datachk['start_date'] =$startyear."-".$smonth."-01";
            $datachk['end_date'] =$endyear."-".$endmonth."-".$lastdate1;


            $datachk['periodicityno']       = $per1[$chkvalue[0]][$key1];
            $datachk['year']                 = $year1[$chkvalue[0]][$key1];
            $datachk['product_status']     =$ps1[$chkvalue[0]][$key1];

            if($comboval == 1 && $datachk['reductionamount']!=0){
                $datachk['combostatus']=1;
            }else{
                $datachk['combostatus']=0;
            }

            $pbyp1=$this->Sub_model->getProductByperiodicity($chkvalue[0]);
            $datapdf['products'][]=array("pname"=>$pbyp1->productname,"cliname"=>$cliname,"abbr"=>$pbyp1->productshortname,"pername"=>$datachk['periodicityno'],
            "year"=>$datachk['year'],"subtype"=>$st1[$chkvalue[0]][$key1],"perno"=>$pbyp1->periodicity,"dur"=>$pbyp1->duration,"randid"=>$prodId,"prodid"=>$chkvalue[0]);

            $this->Sub_model->addSubscribedProduct($datachk);
            }
        } 

Model

function addSubscribedProduct($data) {

      foreach ($data as $key => $value) {

           if ($value=="") {

                 $array[$key] =0;
           }else{

                 $array[$key] =$value;
            }
      }

  $res = $this->db->insert('iman_subscribed_products', $array);       
//$res = $this->db->insert_batch('iman_subscribed_products', $array);
//echo $sql = $this->db->last_query(); 

         if($res) {
              return 1;
         } else {
              return 0;
         }

}

Screen shot of my form

enter image description here

  • 写回答

2条回答 默认 最新

  • dongying6179 2016-08-08 10:57
    关注

    i think you stumpled into php's max_input_vars option

    the standard value for this is 1000

    just change your value to something higher than that

    Be aware you can't change it with ini_set. For more information click here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测