當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Pagina::save方法代碼示例

本文整理匯總了PHP中Pagina::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Pagina::save方法的具體用法?PHP Pagina::save怎麽用?PHP Pagina::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pagina的用法示例。


在下文中一共展示了Pagina::save方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Pagina();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Pagina'])) {
         $model->attributes = $_POST['Pagina'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->pagina_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
開發者ID:franksuarez,項目名稱:fructiferia-yii,代碼行數:17,代碼來源:PaginaController.php

示例2: createAction

 /**
  * Creates a new pagina
  */
 public function createAction()
 {
     if (!$this->request->isPost()) {
         return $this->dispatcher->forward(array("controller" => "pagina", "action" => "index"));
     }
     $pagina = new Pagina();
     $pagina->setPaginaNombrecontrolador($this->request->getPost("pagina_nombreControlador"));
     $pagina->setPaginaNombreaccion($this->request->getPost("pagina_nombreAccion"));
     if (!$pagina->save()) {
         foreach ($pagina->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->dispatcher->forward(array("controller" => "pagina", "action" => "new"));
     }
     $this->flash->success("pagina was created successfully");
     return $this->dispatcher->forward(array("controller" => "pagina", "action" => "index"));
 }
開發者ID:munozdaniel,項目名稱:sya,代碼行數:20,代碼來源:PaginaController.php

示例3: guardar

 public function guardar()
 {
     $dir = $this->imageRoute;
     $image_base = Yii::getPathOfAlias('webroot') . '/images/';
     if ($this->validate()) {
         if (isset($this->id)) {
             //Actualizando
             $micrositio = Micrositio::model()->findByPk($this->id);
         } else {
             //Nuevo registro
             $micrositio = new Micrositio();
         }
         $transaccion = $micrositio->dbConnection->beginTransaction();
         $micrositio->seccion_id = 3;
         //Especiales
         $micrositio->nombre = $this->nombre;
         if ($this->imagen != $micrositio->background) {
             if (file_exists($image_base . $micrositio->background)) {
                 @unlink($image_base . $micrositio->background);
             }
             $micrositio->background = $dir . $this->imagen;
         }
         if ($this->imagen_mobile != $micrositio->background_mobile) {
             if (file_exists($image_base . $micrositio->background_mobile)) {
                 @unlink($image_base . $micrositio->background_mobile);
             }
             $micrositio->background_mobile = $dir . $this->imagen_mobile;
         }
         if ($this->miniatura != $micrositio->miniatura) {
             if (file_exists($image_base . $micrositio->miniatura)) {
                 @unlink($image_base . $micrositio->miniatura);
             }
             $micrositio->miniatura = $dir . $this->miniatura;
         }
         $micrositio->destacado = $this->destacado;
         $micrositio->estado = $this->estado;
         if (!$micrositio->save(false)) {
             $transaccion->rollback();
         }
         $micrositio_id = $micrositio->getPrimaryKey();
         if (isset($this->id)) {
             $pagina = Pagina::model()->findByAttributes(array('micrositio_id' => $micrositio_id));
         } else {
             $pagina = new Pagina();
             $pagina->micrositio_id = $micrositio_id;
             $pagina->tipo_pagina_id = 10;
             //Página bloques
         }
         $pagina->nombre = $this->nombre;
         $pagina->meta_descripcion = $this->meta_descripcion;
         $pagina->clase = NULL;
         $pagina->destacado = $this->destacado;
         $pagina->estado = $this->estado == 2 ? 1 : $this->estado;
         if (!$pagina->save(false)) {
             $transaccion->rollback();
         }
         $pagina_id = $pagina->getPrimaryKey();
         if (isset($this->id)) {
             //Actualizando
             $pgB = PgBloques::model()->findByAttributes(array('pagina_id' => $pagina_id));
         } else {
             if (!$micrositio->asignar_pagina($pagina)) {
                 $transaccion->rollback();
             }
             $pgB = new PgBloques();
             $pgB->pagina_id = $pagina_id;
         }
         $pgB->estado = $this->estado;
         if (!$pgB->save(false)) {
             $transaccion->rollback();
             return false;
         } else {
             $transaccion->commit();
             $this->id = $micrositio_id;
             return true;
         }
     } else {
         return false;
     }
 }
開發者ID:Telemedellin,項目名稱:tm,代碼行數:80,代碼來源:EspecialesForm.php

示例4: test2

 public function test2()
 {
     /**
      * Consultas:
      * 
      * SELECT MAX(id) AS max FROM test_a004_pagina
      * 
      * INSERT INTO test_a004_pagina ( titulo ,contenido ,class ,deleted ,owner_id ,id ) VALUES ('Pagina raiz' ,'This step is usually done transparently as most compilers perform it and then invoke the assembler themselves, so you don\'t really have to worry about it. It can be useful later on if you\'re trying to...' ,'Pagina' ,'0' ,NULL ,'1' );
      * 
      * SELECT MAX(id) AS max FROM test_a004_pagina
      * 
      * INSERT INTO test_a004_pagina ( titulo ,contenido ,class ,deleted ,owner_id ,id ) VALUES ('Subpagina de raiz 1' ,'This step is usually done transparently as most compilers perform it and then invoke the assembler themselves, so you don\'t really have to worry about it. It can be useful later on if you\'re trying to...' ,'Pagina' ,'0' ,'1' ,'2' );
      * 
      * SELECT MAX(id) AS max FROM test_a004_pagina
      * 
      * INSERT INTO test_a004_pagina ( titulo ,contenido ,class ,deleted ,owner_id ,id ) VALUES ('Sub subpagina de raiz 1' ,'This step is usually done transparently as most compilers perform it and then invoke the assembler themselves, so you don\'t really have to worry about it. It can be useful later on if you\'re trying to...' ,'Pagina' ,'0' ,'2' ,'3' );
      *
      * SELECT count(id) as cant FROM test_a004_pagina_subpages_test_a004_pagina WHERE (test_a004_pagina_subpages_test_a004_pagina.owner_id=2 AND test_a004_pagina_subpages_test_a004_pagina.ref_id=3)
      * 
      * SELECT MAX(id) AS max FROM test_a004_pagina_subpages_test_a004_pagina
      * 
      * INSERT INTO test_a004_pagina_subpages_test_a004_pagina ( owner_id ,ref_id ,type ,ord ,class ,deleted ,id ) VALUES ('2' ,'3' ,'2' ,NULL ,'ObjectReference' ,'0' ,'1' );
      * 
      * SELECT MAX(id) AS max FROM test_a004_pagina
      * 
      * INSERT INTO test_a004_pagina ( titulo ,contenido ,class ,deleted ,owner_id ,id ) VALUES ('Sub subpagina de raiz 2' ,'This step is usually done transparently as most compilers perform it and then invoke the assembler themselves, so you don\'t really have to worry about it. It can be useful later on if you\'re trying to...' ,'Pagina' ,'0' ,'2' ,'4' );
      * 
      * SELECT count(id) as cant FROM test_a004_pagina_subpages_test_a004_pagina WHERE (test_a004_pagina_subpages_test_a004_pagina.owner_id=2 AND test_a004_pagina_subpages_test_a004_pagina.ref_id=4)
      * 
      * SELECT MAX(id) AS max FROM test_a004_pagina_subpages_test_a004_pagina
      * 
      * INSERT INTO test_a004_pagina_subpages_test_a004_pagina ( owner_id ,ref_id ,type ,ord ,class ,deleted ,id ) VALUES ('2' ,'4' ,'2' ,NULL ,'ObjectReference' ,'0' ,'2' );
      * 
      * SELECT count(id) as cant FROM test_a004_pagina_subpages_test_a004_pagina WHERE (test_a004_pagina_subpages_test_a004_pagina.owner_id=1 AND test_a004_pagina_subpages_test_a004_pagina.ref_id=2)
      * 
      * SELECT MAX(id) AS max FROM test_a004_pagina_subpages_test_a004_pagina
      * 
      * INSERT INTO test_a004_pagina_subpages_test_a004_pagina ( owner_id ,ref_id ,type ,ord ,class ,deleted ,id ) VALUES ('1' ,'2' ,'2' ,NULL ,'ObjectReference' ,'0' ,'3' );
      * 
      * SELECT id FROM test_a004_pagina WHERE id=2
      * 
      * UPDATE test_a004_pagina SET titulo='Subpagina de raiz 1' ,contenido='This step is usually done transparently as most compilers perform it and then invoke the assembler themselves, so you don\'t really have to worry about it. It can be useful later on if you\'re trying to...' ,class='Pagina' ,deleted='0' ,owner_id='1' WHERE id=2
      * 
      * 
      */
     $p1 = new Pagina(array("titulo" => "Pagina raiz", "contenido" => "This step is usually done transparently as most compilers perform it and then invoke the assembler themselves, so you don't really have to worry about it. It can be useful later on if you're trying to..."));
     $p11 = new Pagina(array("titulo" => "Subpagina de raiz 1", "contenido" => "This step is usually done transparently as most compilers perform it and then invoke the assembler themselves, so you don't really have to worry about it. It can be useful later on if you're trying to...", "owner" => $p1));
     $p111 = new Pagina(array("titulo" => "Sub subpagina de raiz 1", "contenido" => "This step is usually done transparently as most compilers perform it and then invoke the assembler themselves, so you don't really have to worry about it. It can be useful later on if you're trying to...", "owner" => $p11));
     $p112 = new Pagina(array("titulo" => "Sub subpagina de raiz 2", "contenido" => "This step is usually done transparently as most compilers perform it and then invoke the assembler themselves, so you don't really have to worry about it. It can be useful later on if you're trying to...", "owner" => $p11));
     // subpaginas de p11
     $p11->addToSubpages($p111);
     $p11->addToSubpages($p112);
     // subpaginas de p1
     $p1->addToSubpages($p11);
     // Guarda en cascada porque el lado con cardinalidad 1 de la relacion
     // es el responsable del lado con cardinalidad *.
     $this->assert($p1->save(), 'TestCaseA004.test2: Test salvar hasMany en cascada', array('errors' => print_r($p1->getErrors(), true)));
     // TODO: en el test verificar que se guardo todo y que puedo cargar las relaciones ok
 }
開發者ID:fkali,項目名稱:yupp,代碼行數:59,代碼來源:apps.tests.tests.TestCaseA004.class.php

示例5: actionSalvarPagina

 /**
  * Action Página : SAVE
  */
 public function actionSalvarPagina()
 {
     $dadosPost = Yii::app()->request->rawBody;
     $parametros = CJSON::decode($dadosPost, true);
     if (isset($parametros['id']) && $parametros['id'] != '') {
         $pagina = Pagina::model()->findByPk($parametros['id']);
     } else {
         $pagina = new Pagina();
     }
     $pagina->nome = $parametros['nome'];
     $pagina->posicao = $parametros['posicao'];
     $response = array();
     if ($pagina->save() === false) {
         $response['success'] = false;
         $response['errors'] = $pagina->errors;
     } else {
         $response['success'] = true;
         $response['pagina'] = $pagina;
     }
     header('Content-type: application/json; charset=utf-8');
     echo CJSON::encode($response);
     Yii::app()->end();
 }
開發者ID:jonaskreling,項目名稱:haras,代碼行數:26,代碼來源:HarasController.php

示例6: actionCrear

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCrear($id, $tipo_pagina_id = 2)
 {
     if (!isset(Yii::app()->session['dirpa'])) {
         Yii::app()->session['dirpa'] = 'backgrounds/paginas/' . date('Y') . '/' . date('m') . '/';
     }
     $micrositio = $id ? Micrositio::model()->with('seccion')->findByPk($id)->id : 0;
     $model = new Pagina();
     $model->micrositio_id = $micrositio;
     $ppc = TipoPagina::model()->findByPk($tipo_pagina_id)->tabla;
     if (!$ppc) {
         throw new Exception(400, "tipo_pagina_id incorrecto");
     }
     $contenido = new $ppc();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Pagina'])) {
         $model->attributes = $_POST['Pagina'];
         $m = Micrositio::model()->with('seccion')->findByPk($_POST['Pagina']['micrositio_id']);
         $model->tipo_pagina_id = $tipo_pagina_id;
         if (isset(Yii::app()->session['dirpa'])) {
             $dirpa = Yii::app()->session['dirpa'];
         }
         $model->background = $_POST['Pagina']['background'] != '' ? $dirpa . $_POST['Pagina']['background'] : NULL;
         $model->background_mobile = $_POST['Pagina']['background_mobile'] != '' ? $dirpa . $_POST['Pagina']['background_mobile'] : NULL;
         $model->miniatura = $_POST['Pagina']['miniatura'] ? $dirpa . $_POST['Pagina']['miniatura'] : NULL;
         if ($model->save()) {
             if (isset($_POST['PgGenericaSt'])) {
                 $contenido->texto = $_POST['PgGenericaSt']['texto'];
             }
             if (isset($_POST['PgArticuloBlog'])) {
                 $contenido->posicion = $_POST['PgArticuloBlog']['posicion'];
                 $contenido->entradilla = $_POST['PgArticuloBlog']['entradilla'];
                 $contenido->texto = $_POST['PgArticuloBlog']['texto'];
                 $contenido->enlace = $_POST['PgArticuloBlog']['enlace'];
                 $contenido->comentarios = $_POST['PgArticuloBlog']['comentarios'];
             }
             if (isset($_POST['PgDocumental'])) {
                 $contenido = PgDocumental::model()->findByPk($_POST['PgDocumental']['id']);
                 $contenido->titulo = $_POST['PgDocumental']['titulo'];
                 $contenido->duracion = $_POST['PgDocumental']['duracion'];
                 $contenido->anio = $_POST['PgDocumental']['anio'];
                 $contenido->sinopsis = $_POST['PgDocumental']['sinopsis'];
             }
             if (isset($_POST['PgFiltro'])) {
                 $contenido->descripcion = $_POST['PgFiltro']['descripcion'];
             }
             if (isset($_POST['PgBloques'])) {
             }
             if (isset($_POST['PgEventos'])) {
                 $contenido->descripcion = $_POST['PgEventos']['descripcion'];
             }
             if (isset($_POST['PgBlog'])) {
                 $contenido->ver_fechas = $_POST['PgBlog']['ver_fechas'];
             }
             if (isset($_POST['PgFormularioJf'])) {
                 $contenido->formulario_id = $_POST['PgFormularioJf']['formulario_id'];
             }
             $contenido->estado = $_POST['Pagina']['estado'];
             $contenido->pagina_id = $model->getPrimaryKey();
             if ($contenido->save()) {
                 $this->redirect(array('view', 'id' => $model->id));
             } else {
                 $model->delete();
             }
         }
     }
     $this->render('crear', array('model' => $model, 'partial' => $ppc, 'contenido' => $contenido));
 }
開發者ID:Telemedellin,項目名稱:tm,代碼行數:72,代碼來源:PaginaController.php

示例7: guardar

 public function guardar()
 {
     $dir = $this->imageRoute;
     $image_base = Yii::getPathOfAlias('webroot') . '/images/';
     if ($this->validate()) {
         if (isset($this->id)) {
             //Actualizando
             $pagina = Pagina::model()->findByPk($this->id);
         } else {
             //Nuevo registro
             $pagina = new Pagina();
         }
         $transaccion = $pagina->dbConnection->beginTransaction();
         $pagina->micrositio_id = 2;
         //Novedades
         $pagina->tipo_pagina_id = 3;
         //Novedad
         $pagina->nombre = $this->nombre;
         $pagina->clase = NULL;
         $pagina->estado = $this->estado;
         $pagina->destacado = $this->destacado;
         if ($this->imagen != $pagina->background) {
             if (file_exists($image_base . $pagina->background)) {
                 @unlink($image_base . $pagina->background);
             }
             $pagina->background = $dir . $this->imagen;
         }
         if ($this->imagen_mobile != $pagina->background_mobile) {
             if (file_exists($image_base . $pagina->background_mobile)) {
                 @unlink($image_base . $pagina->background_mobile);
             }
             $pagina->background_mobile = $dir . $this->imagen_mobile;
         }
         if ($this->miniatura != $pagina->miniatura) {
             if (file_exists($image_base . $pagina->miniatura)) {
                 @unlink($image_base . $pagina->miniatura);
             }
             $pagina->miniatura = $dir . $this->miniatura;
         }
         if (!$pagina->save(false)) {
             $transaccion->rollback();
         }
         $pagina_id = $pagina->getPrimaryKey();
         if (isset($this->id)) {
             //Actualizando
             $pgAB = PgArticuloBlog::model()->findByAttributes(array('pagina_id' => $pagina_id));
         } else {
             //Nuevo registro
             $pgAB = new PgArticuloBlog();
         }
         $pgAB->pagina_id = $pagina_id;
         $pgAB->entradilla = $this->entradilla;
         $pgAB->texto = $this->texto;
         $pgAB->enlace = $this->enlace;
         $pgAB->comentarios = $this->comentarios;
         $pgAB->posicion = $this->posicion;
         $pgAB->estado = $this->estado ? 1 : 0;
         if (!$pgAB->save(false)) {
             $transaccion->rollback();
             return false;
         } else {
             $transaccion->commit();
             $this->id = $pagina_id;
             return true;
         }
     } else {
         return false;
     }
 }
開發者ID:Telemedellin,項目名稱:tm,代碼行數:69,代碼來源:NovedadesForm.php


注:本文中的Pagina::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。