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
     $this->createContextInstance();
     $i = 0;
     $students = StudentPeer::doSelect(new Criteria());
     $career_school_year = CareerSchoolYearPeer::retrieveByPK(4);
     foreach ($students as $student) {
         $this->logSection("Evaluando student ID = ", $student->getId());
         $career_student = $student->getCareerStudent();
         if ($career_student == null) {
             $this->logSection("ceando CarrerStudent", $student->getId());
             $career_student = new CareerStudent();
             $career_student->setStudent($student);
             $career_student->setCareerId(1);
             $career_student->setStartYear(1);
             $career_student->setFileNumber($student->getGlobalFileNumber());
             $career_student->save($connection);
             #$career_student->createStudentsCareerSubjectAlloweds(1, $connection);
             $this->logSection("Fin creacion careerStudent", $career_student->getId());
         }
         $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year);
         if ($student_career_school_year == null) {
             $i++;
             $this->logSection("Creando studentCareerSchoolYear", $student->getId());
             $student_career_school_year = new StudentCareerSchoolYear();
             $student_career_school_year->setCareerSchoolYear($career_school_year);
             $student_career_school_year->setStudent($student);
             $student_career_school_year->setYear($student->getCareerStudent()->getStartYear());
             $student_career_school_year->save($connection);
             $this->logSection("Fin creacion studentCareerSchoolYear", $career_student->getId());
             $this->logSection("Guardando", $student);
             echo $i;
         }
     }
 }
예제 #2
0
 /**
  * Registers the student for the given career.
  *
  * @param Career $career
  * @param Orientation $orientation
  * @param integer $start_year
  */
 public function registerToCareer(Career $career, Orientation $orientation = null, SubOrientation $sub_orientation = null, $start_year, $con = null)
 {
     if ($con == null) {
         $con = Propel::getConnection(StudentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $career_student = new CareerStudent();
     $career_student->setCareerId($career->getId());
     if ($orientation) {
         $career_student->setOrientationId($orientation->getId());
     }
     if ($sub_orientation) {
         $career_student->setSubOrientationId($sub_orientation->getId());
     }
     $career_student->setStudentId($this->getId());
     $career_student->setStartYear($start_year);
     SchoolBehaviourFactory::getInstance()->setStudentFileNumberForCareer($career_student, $con);
     $career_student->save($con);
     SchoolBehaviourFactory::getInstance()->createStudentCareerSubjectAlloweds($career_student, $start_year, $con);
 }