Esempio n. 1
0
 /**
  * Returns the number of disapproved for the given school year.
  *
  * @param SchoolYear $school_year
  * @return integer the disapproved count
  */
 public function countDisapprovedForSchoolYear(SchoolYear $school_year, PropelPDO $con = null)
 {
     $con = is_null($con) ? Propel::getConnection() : $con;
     $c = new Criteria();
     $c->addJoin(StudentDisapprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, CourseSubjectStudentPeer::ID);
     $c->add(CourseSubjectStudentPeer::STUDENT_ID, $this->getId());
     $previous_ids = array_map(create_function('$c', 'return $c->getId();'), CourseSubjectStudentPeer::doSelect($c));
     $c = new Criteria();
     $c->add(CourseSubjectStudentPeer::STUDENT_ID, $this->getId());
     $c->add(CoursePeer::SCHOOL_YEAR_ID, $school_year->getId());
     $c->addJoin(CoursePeer::ID, CourseSubjectPeer::COURSE_ID);
     $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID);
     $c->addJoin(CourseSubjectStudentPeer::ID, StudentDisapprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID);
     $c->add(StudentDisapprovedCourseSubjectPeer::STUDENT_APPROVED_CAREER_SUBJECT_ID, null, Criteria::ISNULL);
     $c->add(StudentDisapprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, $previous_ids, Criteria::NOT_IN);
     return StudentDisapprovedCourseSubjectPeer::doCount($c, $con);
 }