public function save() { $con = Propel::getConnection(); try { $con->beginTransaction(); foreach ($this->students as $student) { $student_attendance = StudentAttendancePeer::retrieveOrCreate($student, $this->course_subject_id, $this->day, $this->career_school_year_id); $name = 'student_attendance_' . $student->getId() . '_' . $this->day; $this->setStudentAttendanceValue($name, $student_attendance); $student_attendance->save($con); } $con->commit(); } catch (PropelExeption $e) { $con->rollBack(); throw $e; } }
public function save() { $con = Propel::getConnection(); try { $con->beginTransaction(); foreach ($this->students as $student) { foreach ($this->days as $day => $day_i) { $student_attendance = StudentAttendancePeer::retrieveOrCreate($student, $this->course_subject_id, $day_i, $this->career_school_year_id); if (!$this->getValue('day_disabled_' . $day)) { $name = 'student_attendance_' . $student->getId() . '_' . $day; $this->setStudentAttendanceValue($name, $student_attendance); $student_attendance->save($con); } elseif (!$student_attendance->isNew()) { $student_attendance->delete($con); } } } $con->commit(); } catch (PropelExeption $e) { $con->rollBack(); throw $e; } }