HY000 - 2014 - Cannot execute queries while other

2019-08-29 20:40发布

问题:

Statement could not be executed (HY000 - 2014 - Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED i got this error while running an action in zf2, how to solve this issue

{ $assSub=$this->getTblInstitutesDepartmentsTable()->getAssignedDetails($urlassId);

$request = $this->getRequest();

    if($request->isPost()){
       $submittedArray = $request->getPost()->toArray();
       $remarks = $submittedArray['remark'];
       $grades  = $submittedArray['grade'];
       $submittedChk =$submittedArray['submitted'];      
       foreach ($submittedChk as $submitted){ 
             $chksubmitted = 1;                 
             $remark = $remarks[$submitted];    
             $grade  = $grades[$submitted];
                $submittedObj =  new TblInstitutesDepartmentModel(array('asid' => $sub,'gd_id' => $grd,'rem' => $rem,'is_sub' => $chksub,'sub_date'=>date('Y-m-d')));                    
                $this->getTblInstitutesDepartmentsTable()->updateAssigned($submittedObj);        }           
    }      
    $view = new ViewModel(array(          
        'assStd'  => $assSub,          
        'flashMessages'     => $this->flashMessenger()->getMessages()
            )
    );

回答1:

i just call $this->getTblInstitutesDepartmentsTable()->getAssignedDetails($urlassId) this to view model

// $assSub=$this->getTblInstitutesDepartmentsTable()->getAssignedDetails($urlassId);

$request = $this->getRequest();
if($request->isPost()){

   $submittedArray = $request->getPost()->toArray();

   $remarks = $submittedArray['remark'];

   $grades  = $submittedArray['grade'];

   $submittedChk =$submittedArray['submitted']; 

   foreach ($submittedChk as $submitted){ 

         $chksubmitted = 1;     

         $remark = $remarks[$submitted]; 

         $grade  = $grades[$submitted];

            $submittedObj =  new TblInstitutesDepartmentModel(array('asid' => $sub,'gd_id' => $grd,'rem' => $rem,'is_sub' => $chksub,'sub_date'=>date('Y-m-d'))); 

            $this->getTblInstitutesDepartmentsTable()->updateAssigned($submittedObj);        }           
}      
$view = new ViewModel(array(          
    //'assStd'  => **$assSub**,
      'assStd'  =>  $this->getTblInstitutesDepartmentsTable()->getAssignedDetails($urlassId),       
    'flashMessages'     => $this->flashMessenger()->getMessages()
        )
);