public function addToCurrentCareerSchoolYear(PropelPDO $con = null) { if (is_null($con)) { $con = Propel::getConnection(); } $career_school_year = $this->getCareerSchoolYear(); try { $con->beginTransaction(); $career_subject_school_year = new CareerSubjectSchoolYear(); $career_subject_school_year->setCareerSubject($this); $career_subject_school_year->setCareerSchoolYear($career_school_year); $career_subject_school_year->save($con); $students = StudentPeer::retrieveForCareerSchoolYearAndYear($career_school_year, $this->getYear()); foreach ($students as $student) { $student_career_subject_allowed = new StudentCareerSubjectAllowed(); $student_career_subject_allowed->setCareerSubject($this); $student_career_subject_allowed->setStudent($student); $student_career_subject_allowed->save($con); } $con->commit(); } catch (PropelException $e) { $con->rollback(); throw $e; } }