Beispiel #1
0
 public static function getExamsForYearAndCourseId($courseId, $year, PropelPDO $propelConnection)
 {
     $c = new Criteria();
     $crit1 = $c->getNewCriterion(ExamPeer::COURSE_ID, $courseId);
     $crit2 = $c->getNewCriterion(ExamPeer::YEAR, $year);
     $c->addAnd($crit1);
     $c->addAnd($crit2);
     $c->addAscendingOrderByColumn(ExamPeer::TYPE);
     $c->addAscendingOrderByColumn(ExamPeer::DESCR);
     return ExamPeer::doSelect($c, $propelConnection);
 }
Beispiel #2
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->buildSubmenu($request);
     $id = $request->getParameter("id");
     $conn = Propel::getConnection();
     $this->courseObj = CoursePeer::retrieveByPK($id, $conn);
     if (!is_object($this->courseObj)) {
         $this->forward404();
     }
     // courseDetail
     $detList = $this->courseObj->getCourseDetails(null, $conn);
     if (count($detList) > 0) {
         $this->courseDetail = $detList[0];
     }
     // instructor
     $detList = CourseInstructorAssociationPeer::getLatestInstructorsForCourseId($this->courseObj->getId(), $conn);
     $newList = CourseInstructorAssociationPeer::getHistoricalInstructorsForCourseId($this->courseObj->getId(), $conn);
     if (count($detList) > 0) {
         $this->currentInstructorList = $detList;
         $this->pastInstructorList = $newList;
     }
     // program
     $detList = CourseDisciplineAssociationPeer::getRelatedDisciplinesForCourse($this->courseObj, $conn);
     if (count($detList) > 0) {
         $this->programList = $detList;
     }
     // full exam data
     $conn = Propel::getConnection();
     $c = new Criteria();
     $courseCrit = $c->getNewCriterion(ExamPeer::COURSE_ID, $this->courseObj->getId());
     $c->addAnd($courseCrit);
     $c->addAscendingOrderByColumn(ExamPeer::YEAR);
     $c->addAscendingOrderByColumn(ExamPeer::TYPE);
     $c->addAscendingOrderByColumn(ExamPeer::DESCR);
     $examData = ExamPeer::doSelect($c, $conn);
     // now splice the data up and send it to the frontend
     $this->examData = array();
     $year = "";
     $type = "";
     foreach ($examData as $exam) {
         if ($year != $exam->getYear()) {
             $year = $exam->getYear();
             $this->examData[$year] = array();
             $type = "";
         }
         if ($type != $exam->getType()) {
             $type = $exam->getType();
             $this->examData[$year][$type] = array();
         }
         $this->examData[$year][$type][] = $exam;
     }
 }
Beispiel #3
0
 /**
  * Gets an array of Exam objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this EnumItem has previously been saved, it will retrieve
  * related Exams from storage. If this EnumItem is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array Exam[]
  * @throws     PropelException
  */
 public function getExams($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(EnumItemPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collExams === null) {
         if ($this->isNew()) {
             $this->collExams = array();
         } else {
             $criteria->add(ExamPeer::TYPE, $this->id);
             ExamPeer::addSelectColumns($criteria);
             $this->collExams = ExamPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // 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(ExamPeer::TYPE, $this->id);
             ExamPeer::addSelectColumns($criteria);
             if (!isset($this->lastExamCriteria) || !$this->lastExamCriteria->equals($criteria)) {
                 $this->collExams = ExamPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastExamCriteria = $criteria;
     return $this->collExams;
 }
 protected function getExamList(Criteria $c = null)
 {
     if (isset($c)) {
         return ExamPeer::doSelect($c);
     } else {
         return ExamPeer::doSelect(new Criteria());
     }
 }
Beispiel #5
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(ExamPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(ExamPeer::DATABASE_NAME);
         $criteria->add(ExamPeer::ID, $pks, Criteria::IN);
         $objs = ExamPeer::doSelect($criteria, $con);
     }
     return $objs;
 }