public static function retrieveOrCreateByCareerSubjectAndStudent($career_subject_id, $student_id) { $c = new Criteria(); $c->add(self::CAREER_SUBJECT_ID, $career_subject_id); $c->add(self::STUDENT_ID, $student_id); $sacs = self::doSelectOne($c); if ($sacs == null) { $criteria = new criteria(); $criteria->add(CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID, $career_subject_id); $career_subject_school_years = CareerSubjectSchoolYearPeer::doSelect($criteria); $opcions = array(); foreach ($career_subject_school_years as $career_subject_school_year) { foreach ($career_subject_school_year->getChoices() as $optional_career_subject_school_year) { $cs = CareerSubjectPeer::retrieveByCareerSubjectSchoolYearId($optional_career_subject_school_year->getChoiceCareerSubjectSchoolYearId()); $opcions[] = $cs->getId(); } } $criteria = new criteria(); $criteria->add(self::CAREER_SUBJECT_ID, $opcions, Criteria::IN); $sacs = self::doSelectOne($criteria); if ($sacs == null) { $sacs = new StudentApprovedCareerSubject(); $sacs->setCareerSubjectId($career_subject_id); } } $sacs->setStudentId($student_id); return $sacs; }
public function getExcludeRepprovedSubjects() { $c = new Criteria(); $c->add(CareerSubjectPeer::SUBJECT_ID, self::ED_FISICA); $c->addJoin(CareerSubjectPeer::ID, CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID); $result = array(); foreach (CareerSubjectSchoolYearPeer::doSelect($c) as $career_school_year) { $result[] = $career_school_year->getId(); } return $result; }
/** * This method try to find if there are new CareerSubjects for our Career, recently * created but without a CareerSubjectSchoolYear created * */ public function checkCareerSubjectOptionsIntegrity() { $criteria = new Criteria(); $criteria->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID, Criteria::INNER_JOIN); $criteria->addAnd(CareerSchoolYearPeer::CAREER_ID, $this->getCareerId()); $all_career_subjects_sy = array_map(create_function('$cs', 'return $cs->getCareerSubjectId();'), CareerSubjectSchoolYearPeer::doSelect($criteria)); $criteria->clear(); $criteria->addAnd(CareerSubjectPeer::CAREER_ID, $this->getCareerId()); $criteria->addAnd(CareerSubjectPeer::ID, $all_career_subjects_sy, Criteria::NOT_IN); $con = Propel::getConnection(SchoolYearPeer::DATABASE_NAME); try { foreach (CareerSubjectPeer::doSelect($criteria) as $career_subject) { $career_subject_school_year = new CareerSubjectSchoolYear(); $career_subject_school_year->setCareerSchoolYear($this); $career_subject_school_year->setCareerSubject($career_subject); $career_subject_school_year->save($con); } $con->commit(); } catch (PropelPDOException $e) { $con->rollBack(); throw $e; } }
/** * Get every CareerSubjectSchoolYear that has been marked as 'is_option' that is * available for $career_subject_school_year (the optional CareerSubject). * * @param CareerSubjectSchoolYear $career_subject The optional CareerSubject. * @param Boolean $exclude_related, if its true excludes the related options * @param PropelPDO $con Database connection (can be null). * * @return array OptionalCareerSubject[] */ public function getAvailableChoicesForCareerSubjectSchoolYear(CareerSubjectSchoolYear $career_subject_school_year, $exclude_related = true, PropelPDO $con = null) { $criteria = $this->getAvailableChoicesForCareerSubjectsSchoolYearCriteria($career_subject_school_year, $exclude_related, $con); return CareerSubjectSchoolYearPeer::doSelect($criteria); }
public function getLvmSpecialSubjects($school_year = null) { if (is_null($school_year)) { $school_year = SchoolYearPeer::retrieveCurrent(); } $c = new Criteria(); $c->add(CareerSubjectPeer::SUBJECT_ID, $this->_introduccion, Criteria::IN); $c->addJoin(CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID, CareerSubjectPeer::ID); $c->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID, Criteria::INNER_JOIN); $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $school_year->getId()); return CareerSubjectSchoolYearPeer::doSelect($c); }