本文整理汇总了PHP中Division::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Division::save方法的具体用法?PHP Division::save怎么用?PHP Division::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Division
的用法示例。
在下文中一共展示了Division::save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createByName
public function createByName($name)
{
print_r('[' . $name . ']');
$document = new Division();
$document->setName($name);
$document->setSlug();
$document->save();
$document = $this->findOneBySlug($document->getSlug());
return $document;
}
示例2: load
public function load()
{
$this->clear();
$division = new Division('D1');
$level = $this->CI->_level->findOneBySlug('college');
$division->setLevel($level);
$league = $this->CI->_league->findOneBySlug('ncaa');
$division->setLeague($league);
$division->save();
print_r(sprintf("Created Division: %s (%s)\n", $division->getName(), $division->getId()));
}
示例3: save
public function save()
{
$divisionId = $this->getValue('divisionId');
if (!empty($divisionId)) {
$division = $this->getDivisionService()->getDivisionById($divisionId);
} else {
$division = new Division();
}
$division->setDivisionName($this->getValue('division_name'));
$division->setDivisionCode($this->getValue('division_code'));
$division->setCouCode($this->getValue('country'));
$division->save();
}
示例4: agregar
public function agregar()
{
$data = array();
if ($_POST) {
$division = new Division(elements(array('division'), $_POST));
if ($division->is_valid()) {
$division->save();
$this->session->set_flashdata('msg', '<div class="success">La División se guardó correctamente.</div>');
redirect('divisiones');
} else {
$data['errors'] = $division->errors;
}
}
$data['titulo'] = "Agregar División";
$data['action'] = "divisiones/agregar";
$this->template->write_view('content', 'divisiones/agregar', $data);
$this->template->render();
}
示例5: saveCiclolectivo
protected function saveCiclolectivo($ciclolectivo)
{
//si se guarda el ciclo y se marca como actual
//los demas ciclo del establecimiento tiene que quedar como ACUAL = false
$con = Propel::getConnection();
try {
$con->beginTransaction();
if ($ciclolectivo->getActual()) {
$c1 = new Criteria();
$c1->add(CiclolectivoPeer::FK_ESTABLECIMIENTO_ID, $this->getUser()->getAttribute('fk_establecimiento_id'));
$c2 = new Criteria();
$c2->add(CiclolectivoPeer::ACTUAL, false);
BasePeer::doUpdate($c1, $c2, $con);
}
$ciclolectivo->setFkEstablecimientoId($this->getUser()->getAttribute('fk_establecimiento_id'));
$isNew = $ciclolectivo->isNew();
$ciclolectivo->save();
if ($isNew) {
# Codigo para copiar las divisiones del ciclo lectivo actual al nuevo
# La consulta debe contemplar que lo haga desde el ciclo lectivo actual
if ($this->getRequestParameter('importar')) {
$ciclo_actual = CiclolectivoPeer::retrieveByPk($this->getUser()->getAttribute('fk_ciclolectivo_id'));
if ($ciclo_actual) {
$this->logMessage('ciclo_actual: ' . $ciclo_actual, 'debug');
//clonar turnos
foreach ($ciclo_actual->getTurnos() as $turno) {
$nt = new Turno();
$nt->setFkCiclolectivoId($ciclolectivo->getId());
$nt->setHoraInicio($turno->getHoraInicio());
$nt->setHoraFin($turno->getHoraFin());
$nt->setDescripcion($turno->getDescripcion());
$nt->save();
//clonar las divisiones
foreach ($turno->getDivisions() as $division) {
$this->logMessage('division: ' . $division, 'debug');
$nd = new Division();
$nd->setFkAnioId($division->getFkAnioId());
$nd->setDescripcion($division->getDescripcion());
$nd->setFkTurnoId($nt->getId());
$nd->setFkOrientacionId($division->getFkOrientacionId());
$nd->setOrden($division->getOrden());
$nd->save();
}
}
} else {
//no existe el ciclo actual
$this->getUser()->setFlash('error', 'No hay un ciclo actual seleccionado');
}
}
}
$con->commit();
if ($ciclolectivo->getActual()) {
//cambio el attributo porque se cambio el ciclo actual
$this->getUser()->setAttribute('fk_ciclolectivo_id', $ciclolectivo->getId());
$this->getUser()->setAttribute('ciclolectivo_descripcion', $ciclolectivo->getDescripcion());
}
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
}
示例6: 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');
}
}
示例7: Division
function division_save($office_id = '', $id = '')
{
$data['page_name'] = '<b>Save Division</b>';
$data['msg'] = '';
$divisions = new Division();
$data['division'] = $divisions->get_by_id($id);
$data['office_id'] = $office_id;
if (Input::get('op')) {
$divisions->name = Input::get('name');
$divisions->description = Input::get('description');
$divisions->office_id = $office_id;
$divisions->order = Input::get('order');
$divisions->save();
Session::flash('msg', 'Division has been saved!');
return Redirect::to('office_manage/divisions/' . $office_id, 'refresh');
}
$data['main_content'] = 'division_save';
return View::make('includes/template', $data);
}
示例8: createCopyForSchoolYear
public function createCopyForSchoolYear(PropelPDO $con = null, $career_school_year)
{
$copy_division = new Division();
$copy_division->setDivisionTitle($this->getDivisionTitle());
$copy_division->setCareerSchoolYear($career_school_year);
$copy_division->setShift($this->getShift());
$copy_division->setYear($this->getYear());
$copy_division->save($con);
$this->copyPreceptorsToDivision($con, $copy_division);
$this->copyCoursesToDivision($con, $copy_division, $career_school_year);
if ($this->getYear() <= $career_school_year->getCareer()->getQuantityYears() && $this->getYear() > 1) {
$copy_division->createStudentsForNextYear($con, $this->getCareerSchoolYear());
}
$copy_division->clearAllReferences(true);
unset($copy_division);
$career_school_year->clearAllReferences(true);
unset($career_school_year);
$this->clearAllReferences(true);
}