I am trying to update grades of student using update batch (multiple update)
However the problem arises when conditioning in the model, whereas the array condition does not accept else if statement
in this line, 'equiv' => $data['grade'][$i] == 65 ? 5 : 0, is there a way to make it a full condition statement where I can use else if and remove the else or
:0at the end of the line. The:0makes all other data 0 which those data should not be affected.
public function updateAll(){
$id = $this->input->post('studentID');
$data = $this->input->post();
for($i = 0; $i < (count($data['studentID'])); $i++){
$batch[] = array(
'studentID' => $data['studentID'][$i],
'grade' => $data['grade'][$i],
'equiv' => $data['grade'][$i] == 65 ? 5 : 0
);
}
return $this->db->update_batch('tbl_college_grades', $batch, 'studentID');
}