當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Division::addDivisionCourse方法代碼示例

本文整理匯總了PHP中Division::addDivisionCourse方法的典型用法代碼示例。如果您正苦於以下問題:PHP Division::addDivisionCourse方法的具體用法?PHP Division::addDivisionCourse怎麽用?PHP Division::addDivisionCourse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Division的用法示例。


在下文中一共展示了Division::addDivisionCourse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     // add your code here
     $courses = CoursePeer::doSelect(new Criteria());
     foreach ($courses as $course) {
         $division = new Division();
         $division->setName($course->getName());
         $division->setSchoolYearId($course->getSchoolYearId());
         foreach ($course->getCourseSubjects() as $course_subject) {
             $course_students = $course->getCourseStudents();
             if (isset($course_students[0])) {
                 $division->setCareerId($course_students[0]->getCareerSubject()->getCareerId());
             } else {
                 $division->setCareerId(1);
             }
             $new_course = new Course();
             $course->copyInto($new_course);
             $new_course->setName($course_subject->getSubject() . ' - ' . $course->getName());
             $new_course->save();
             $new_course_subject = new CourseSubject();
             $course_subject->copyInto($new_course_subject);
             $new_course_subject->setCourseId($new_course->getId());
             $new_course_subject->setCourseId($new_course->getId());
             $new_course_subject->save();
             $course_subject->delete();
             $c = new Criteria();
             $c->add(CourseStudentPeer::COURSE_ID, $course->getId());
             $c->addJoin(CourseStudentPeer::CAREER_SUBJECT_ID, CareerSubjectPeer::ID);
             $c->add(CareerSubjectPeer::SUBJECT_ID, $new_course_subject->getSubjectId());
             $course_students = CourseStudentPeer::doSelect($c);
             foreach ($course_students as $course_student) {
                 $new_course_student = new CourseStudent();
                 $course_student->copyInto($new_course_student);
                 $new_course_student->setCourseId($new_course->getId());
                 $new_course_student->save();
                 $course_student->delete();
             }
             $division_course = new DivisionCourse();
             $division_course->setCourse($new_course);
             $division->addDivisionCourse($division_course);
         }
         try {
             $course->delete();
         } catch (Exception $e) {
         }
         try {
             $division->save();
         } catch (Exception $e) {
         }
         $this->logSection('division+', 'Division ' . $division . ' created');
     }
 }
開發者ID:nvidela,項目名稱:kimkelen,代碼行數:55,代碼來源:dcCreatedivisionsfromcoursesTask.class.php


注:本文中的Division::addDivisionCourse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。