My current problem is that all data are being updated all at once when I use update_batch()
, is there a way to update only the last data?
I am updating grades every semester that is why I need to update the latest grades in this semester. However whenever I update grades, the latest update will also update the previous grades in my semester that is why it is being overwritten. Hence, I only want to update the latest grades in this semester. I also used update_batch
to update multiple records, am I wrong doing so?
Here is my controller:
$schoolYear = $csvData[0]['schoolYear'];
$semester = $csvData[0]['semester'];
$studentIDFromDB = $this->importSISAcademicInformationGetStudentIDFromDB($schoolYear, $semester);
foreach ($csvData as $key => $value) {
if(isset($studentIDFromDB[$value['studentID']])){
$updateFields[$key] = array(
'studentID' => $value['studentID'],
'programType' => $value['programType'],
'level' => $value['level'],
'sectionDescription' => $value['sectionDescription'],
'schoolYear' => $value['schoolYear'],
'semester' => $value['semester']
);
}
}
if(isset($updateFields))
$this->DBLogic->updateBatchRecordMultipleCondition('tbl_tt_academicinfo', $updateFields, 'studentID', array('schoolYear' => $schoolYear, 'semester' => $semester));
Here is my Model:
public function updateBatchRecordMultipleCondition($table, $fields, $criteria1, $criteriaN){
$this->db->where($criteriaN);
$this->db->update_batch($table, $fields, $criteria1);
}