コード例 #1
0
 public function updateCourse(Course $c)
 {
     $sql = "UPDATE course  SET courseName = ?, creditHour= ?, contactHour = ?  WHERE courseNumber=?";
     $params = array($c->getCourseName(), $c->getCreditHour(), $c->getContactHour(), $c->getCourseNumber());
     $query = $this->db->prepare($sql);
     $res = $query->execute($params);
     return $res;
 }
コード例 #2
0
 /**
  * Get all users that are registered in the course. No matter the status
  *
  * @param Course $course
  * @return \Doctrine\ORM\QueryBuilder
  */
 public function getSubscribedUsers(Course $course)
 {
     $queryBuilder = $this->createQueryBuilder('a');
     // Selecting user info.
     $queryBuilder->select('DISTINCT u');
     // Loading EntityUser.
     $queryBuilder->from('Entity\\User', 'u');
     // Selecting courses for users.
     $queryBuilder->innerJoin('u.courses', 'c');
     //@todo check app settings
     $queryBuilder->add('orderBy', 'u.lastname ASC');
     $wherePart = $queryBuilder->expr()->andx();
     // Get only users subscribed to this course
     $wherePart->add($queryBuilder->expr()->eq('c.cId', $course->getId()));
     // $wherePart->add($queryBuilder->expr()->eq('c.status', $status));
     $queryBuilder->where($wherePart);
     //$q = $queryBuilder->getQuery();
     //return $q->execute();
     return $queryBuilder;
 }
コード例 #3
0
 /**
  *
  * @return \Entity\Course 
  */
 public static function current_course()
 {
     static $result = false;
     if ($result === false) {
         $repo = \Entity\Course::repository();
         $course_id = api_get_course_int_id();
         if ($course_id) {
             $result = $repo->find($course_id);
         }
     }
     return $result;
 }
コード例 #4
0
 public function testInsertCourse()
 {
     $course = new Course();
     $course->setCourseNumber("091");
     $course->setCourseName("IS");
     $course->setCreditHour(4);
     $course->setContactHour(7);
     $dao = new CourseDAO();
     $dao->insertCourse($course);
     assert($dao->getCourseById("091")->getCourseName() == "IS");
 }