I have a collection name StudentMarks
with 20000 records in my MongoDB
. I am running a script to update a field in all documents of this collection. I am getting following error after it process 5000 records. I am unable to find out why this is happening and how to resolve it.
Error Is : Mongo Cursor Could not found on line 1125
Following code I have written in controller
public function updateAction(Request $request) {
$examStudentMarkDocument11 = $schoolDM - > getRepository('EduExamCbseBundle:ExamCbseStudentSubjectMark') - > findAll();
if (count($examStudentMarkDocument11)) {
$i = 0;
// MongoCursor::$timeout = -1;
foreach($examStudentMarkDocument11 as $stdnt) {
$id = $stdnt - > getId();
$examStudentMarkDocument1 = $schoolDM - > getRepository('EduExamCbseBundle:ExamCbseStudentSubjectMark') - > find($id);
$examStudentMarkDocument1 - > setCurrentSession($currentSessionYear); //Updating field here
$schoolDM - > persist($examStudentMarkDocument1);
$schoolDM - > flush();
$i++;
}
}
}