本文整理汇总了PHP中Division::setCareerId方法的典型用法代码示例。如果您正苦于以下问题:PHP Division::setCareerId方法的具体用法?PHP Division::setCareerId怎么用?PHP Division::setCareerId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Division
的用法示例。
在下文中一共展示了Division::setCareerId方法的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');
}
}