我试图一次插入100多条记录。如果他们表格中的更多记录将不会执行任何操作,除非它将提交并重定向到另一页面。
如何解决此错误。
我也尝试过使用insert_batch。但没用。 我也改变了php.ini post_max_size,
有人请帮助我。
以下是我的控制器和模型代码
控制器代码
.tbc
模型
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);
}
}
我的表格的屏幕截图
答案 0 :(得分:0)
用户insert_batch()而不是insert(),如下所示:
$这 - &GT; DB-&GT; insert_batch(阵列)); //这里的数组是多维的,可以包含100行的行数。
答案 1 :(得分:0)