Пример #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $genero = new Genero();
     $genero->nombre = Request::get('nombre');
     $genero->descripcion = Request::get('descripcion');
     $genero->funcionarioId = Auth::user()->id;
     $genero->save();
     return Response::json(array('error' => false, 'generos' => $genero->toArray()), 200);
 }
Пример #2
0
 /**
  * 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->aUsuario !== null) {
             if ($this->aUsuario->isModified() || $this->aUsuario->isNew()) {
                 $affectedRows += $this->aUsuario->save($con);
             }
             $this->setUsuario($this->aUsuario);
         }
         if ($this->aGenero !== null) {
             if ($this->aGenero->isModified() || $this->aGenero->isNew()) {
                 $affectedRows += $this->aGenero->save($con);
             }
             $this->setGenero($this->aGenero);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->lista_audiolibrosScheduledForDeletion !== null) {
             if (!$this->lista_audiolibrosScheduledForDeletion->isEmpty()) {
                 Lista_audiolibroQuery::create()->filterByPrimaryKeys($this->lista_audiolibrosScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->lista_audiolibrosScheduledForDeletion = null;
             }
         }
         if ($this->collLista_audiolibros !== null) {
             foreach ($this->collLista_audiolibros as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Пример #3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCrear()
 {
     $genero = new Genero();
     if (isset($_POST['Genero'])) {
         $genero->attributes = $_POST['Genero'];
         if ($genero->save()) {
             Yii::app()->user->setFlash('success', 'Género ' . $genero->nombre . ' guardado con éxito');
             $this->redirect(array('view', 'id' => $genero->getPrimaryKey()));
         }
         //if($genero->save())
     }
     //if(isset($_POST['MenuItem']))
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $this->render('crear', array('model' => $genero));
 }
 /**
  * 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->aUsuario !== null) {
             if ($this->aUsuario->isModified() || $this->aUsuario->isNew()) {
                 $affectedRows += $this->aUsuario->save($con);
             }
             $this->setUsuario($this->aUsuario);
         }
         if ($this->aGenero !== null) {
             if ($this->aGenero->isModified() || $this->aGenero->isNew()) {
                 $affectedRows += $this->aGenero->save($con);
             }
             $this->setGenero($this->aGenero);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Пример #5
0
include_once "../../data/config.php";
//echo "<pre>";print_r(json_decode($_POST['json']));  echo "</pre>";
$datos = json_decode($_POST['json']);
//$libros = LibroQuery::create()->find();
//$usuarios = UsuarioQuery::create()->find();
switch ($datos->accion) {
    case "e":
        //Edit
        $generoObj = GeneroQuery::create()->findOneById($datos->id);
        //echo $generosObj->toArray();
        $generoObj->setNombre($datos->nombre);
        $generoObj->save();
        echo json_encode(array('error' => 0, 'msg' => "Genero modificado correctamente"));
        break;
    case "d":
        //Delete
        $generoObj = GeneroQuery::create()->findOneById($datos->id);
        //$objTerapia = TerapiasQuery::create()->findOneById($_GET["id"]);
        if ($generoObj != null) {
            $generoObj->delete();
        }
        echo json_encode(array('error' => 0, 'msg' => "genero borrado correctamente"));
        break;
    case "n":
        //New
        $generoObj = new Genero();
        $generoObj->setNombre($datos->nombre);
        $generoObj->save();
        echo json_encode(array('error' => 0, 'msg' => "Genero creado correctamente"));
        break;
}
Пример #6
0
 /**
  * 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->aUsuarioRelatedByUsuario_ult_acc !== null) {
             if ($this->aUsuarioRelatedByUsuario_ult_acc->isModified() || $this->aUsuarioRelatedByUsuario_ult_acc->isNew()) {
                 $affectedRows += $this->aUsuarioRelatedByUsuario_ult_acc->save($con);
             }
             $this->setUsuarioRelatedByUsuario_ult_acc($this->aUsuarioRelatedByUsuario_ult_acc);
         }
         if ($this->aPrivacidad !== null) {
             if ($this->aPrivacidad->isModified() || $this->aPrivacidad->isNew()) {
                 $affectedRows += $this->aPrivacidad->save($con);
             }
             $this->setPrivacidad($this->aPrivacidad);
         }
         if ($this->aGenero !== null) {
             if ($this->aGenero->isModified() || $this->aGenero->isNew()) {
                 $affectedRows += $this->aGenero->save($con);
             }
             $this->setGenero($this->aGenero);
         }
         if ($this->aUsuarioRelatedById_usuario !== null) {
             if ($this->aUsuarioRelatedById_usuario->isModified() || $this->aUsuarioRelatedById_usuario->isNew()) {
                 $affectedRows += $this->aUsuarioRelatedById_usuario->save($con);
             }
             $this->setUsuarioRelatedById_usuario($this->aUsuarioRelatedById_usuario);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->audiolibrosScheduledForDeletion !== null) {
             if (!$this->audiolibrosScheduledForDeletion->isEmpty()) {
                 AudiolibroQuery::create()->filterByPrimaryKeys($this->audiolibrosScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->audiolibrosScheduledForDeletion = null;
             }
         }
         if ($this->collAudiolibros !== null) {
             foreach ($this->collAudiolibros as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->calificacionsScheduledForDeletion !== null) {
             if (!$this->calificacionsScheduledForDeletion->isEmpty()) {
                 CalificacionQuery::create()->filterByPrimaryKeys($this->calificacionsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->calificacionsScheduledForDeletion = null;
             }
         }
         if ($this->collCalificacions !== null) {
             foreach ($this->collCalificacions as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->comentariosScheduledForDeletion !== null) {
             if (!$this->comentariosScheduledForDeletion->isEmpty()) {
                 ComentarioQuery::create()->filterByPrimaryKeys($this->comentariosScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->comentariosScheduledForDeletion = null;
             }
         }
         if ($this->collComentarios !== null) {
             foreach ($this->collComentarios as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->libro_colaboradorsScheduledForDeletion !== null) {
             if (!$this->libro_colaboradorsScheduledForDeletion->isEmpty()) {
                 Libro_colaboradorQuery::create()->filterByPrimaryKeys($this->libro_colaboradorsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->libro_colaboradorsScheduledForDeletion = null;
             }
         }
         if ($this->collLibro_colaboradors !== null) {
             foreach ($this->collLibro_colaboradors as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->libro_versionsScheduledForDeletion !== null) {
             if (!$this->libro_versionsScheduledForDeletion->isEmpty()) {
                 Libro_versionQuery::create()->filterByPrimaryKeys($this->libro_versionsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->libro_versionsScheduledForDeletion = null;
             }
         }
         if ($this->collLibro_versions !== null) {
             foreach ($this->collLibro_versions as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->solicitudsScheduledForDeletion !== null) {
             if (!$this->solicitudsScheduledForDeletion->isEmpty()) {
                 SolicitudQuery::create()->filterByPrimaryKeys($this->solicitudsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->solicitudsScheduledForDeletion = null;
             }
         }
         if ($this->collSolicituds !== null) {
             foreach ($this->collSolicituds as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->slider_maesScheduledForDeletion !== null) {
             if (!$this->slider_maesScheduledForDeletion->isEmpty()) {
                 Slider_maeQuery::create()->filterByPrimaryKeys($this->slider_maesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->slider_maesScheduledForDeletion = null;
             }
         }
         if ($this->collSlider_maes !== null) {
             foreach ($this->collSlider_maes as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->postulantessScheduledForDeletion !== null) {
             if (!$this->postulantessScheduledForDeletion->isEmpty()) {
                 PostulantesQuery::create()->filterByPrimaryKeys($this->postulantessScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->postulantessScheduledForDeletion = null;
             }
         }
         if ($this->collPostulantess !== null) {
             foreach ($this->collPostulantess as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->clasificadossScheduledForDeletion !== null) {
             if (!$this->clasificadossScheduledForDeletion->isEmpty()) {
                 ClasificadosQuery::create()->filterByPrimaryKeys($this->clasificadossScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->clasificadossScheduledForDeletion = null;
             }
         }
         if ($this->collClasificadoss !== null) {
             foreach ($this->collClasificadoss as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }