/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Professor(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Professor'])) { $model->attributes = $_POST['Professor']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id_professor)); } } $this->render('create', array('model' => $model)); }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aProfessor !== null) { if ($this->aProfessor->isModified() || $this->aProfessor->isNew()) { $affectedRows += $this->aProfessor->save($con); } $this->setProfessor($this->aProfessor); } if ($this->aResearchline !== null) { if ($this->aResearchline->isModified() || $this->aResearchline->isNew()) { $affectedRows += $this->aResearchline->save($con); } $this->setResearchline($this->aResearchline); } if ($this->isNew()) { $this->modifiedColumns[] = ResearchlineprofessorPeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = ResearchlineprofessorPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += ResearchlineprofessorPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
public function add() { $tabla = Input::get('tabla'); switch ($tabla) { case '0': $clave = Input::get('clave'); $appat = Input::get('ap_pat'); $apmat = Input::get('ap_mat'); $nombre = Input::get('nombre'); $segnombre = Input::get('seg_nombre'); $tipo = Input::get('tipo'); $grado = Input::get('grado'); $tutorias = Input::get('tutorias'); $gestion = Input::get('gestion'); $invest = Input::get('invest'); $depend = Input::get('depend'); $add = new Professor(); $add->clave = $clave; $add->ap_pat = $appat; $add->ap_mat = $apmat; $add->nombre = $nombre; $add->seg_nombre = $segnombre; $add->tipo = $tipo; $add->id_grado = $grado; $add->tutorias = $tutorias; $add->gestion = $gestion; $add->investigacion = $invest; $add->dependencias = $depend; $add->save(); return View::make('crud.crudMaestros')->with('professors', Professor::all()); break; case '1': $nombre = Input::get('nombre'); $semestre = Input::get('semestre'); $plan = Input::get('idPlan'); $add = new Subject(); $add->nombre = $nombre; $add->semestre = $semestre; $add->id_plan = $plan; $add->save(); return View::make('crud.crudMaterias')->with('subjects', Subject::all()); break; case '2': $nombre = Input::get('nombre'); $add = new Aula(); $add->nombre = $nombre; $add->save(); return View::make('crud.crudAulas')->with('aulas', Aula::all()); break; case '3': $nombre = Input::get('nombre'); $add = new Plan(); $add->nombre = $nombre; $add->save(); return View::make('crud.crudPlanes')->with('plans', Plan::all()); break; default: //aqui me redirecciona a una pagina vacia solo con un mensaje 404 return View::make('landing'); break; } }