Esempio n. 1
0
 public static function getAvailableInstructorsForCourseIdAndYear($courseId, $year, PropelPDO $conn)
 {
     $query = "SELECT DISTINCT %s as i FROM %s JOIN %s ON %s=%s WHERE %s='%s' AND %s=%s";
     $query = sprintf($query, CourseInstructorAssociationPeer::ID, AutoCourseRatingPeer::TABLE_NAME, CourseInstructorAssociationPeer::TABLE_NAME, AutoCourseRatingPeer::COURSE_INS_ID, CourseInstructorAssociationPeer::ID, CourseInstructorAssociationPeer::COURSE_ID, $courseId, CourseInstructorAssociationPeer::YEAR, $year);
     $statement = $conn->prepare($query);
     $statement->execute();
     $ids = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
     $results = array();
     $c = new Criteria();
     $c->addJoin(CourseInstructorAssociationPeer::INSTRUCTOR_ID, InstructorPeer::ID);
     foreach ($ids as $id) {
         $crit = $c->getNewCriterion(CourseInstructorAssociationPeer::ID, $id);
         $c->addOr($crit);
     }
     $c->addAscendingOrderByColumn(InstructorPeer::LAST_NAME);
     $c->addAscendingOrderByColumn(InstructorPeer::FIRST_NAME);
     $raw = CourseInstructorAssociationPeer::doSelectJoinInstructor($c, $conn);
     foreach ($raw as $obj) {
         $results[] = $obj->getInstructor();
     }
     return $results;
 }
Esempio n. 2
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Course is new, it will return
  * an empty collection; or if this Course has previously
  * been saved, it will retrieve related CourseInstructorAssociations from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Course.
  */
 public function getCourseInstructorAssociationsJoinInstructor($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(CoursePeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collCourseInstructorAssociations === null) {
         if ($this->isNew()) {
             $this->collCourseInstructorAssociations = array();
         } else {
             $criteria->add(CourseInstructorAssociationPeer::COURSE_ID, $this->id);
             $this->collCourseInstructorAssociations = CourseInstructorAssociationPeer::doSelectJoinInstructor($criteria, $con, $join_behavior);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(CourseInstructorAssociationPeer::COURSE_ID, $this->id);
         if (!isset($this->lastCourseInstructorAssociationCriteria) || !$this->lastCourseInstructorAssociationCriteria->equals($criteria)) {
             $this->collCourseInstructorAssociations = CourseInstructorAssociationPeer::doSelectJoinInstructor($criteria, $con, $join_behavior);
         }
     }
     $this->lastCourseInstructorAssociationCriteria = $criteria;
     return $this->collCourseInstructorAssociations;
 }