本文整理匯總了PHP中Bloque::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Bloque::model方法的具體用法?PHP Bloque::model怎麽用?PHP Bloque::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Bloque
的用法示例。
在下文中一共展示了Bloque::model方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$bloque = Bloque::model()->findByPk($id);
if (isset($_POST['Bloque'])) {
$bloque->attributes = $_POST['Bloque'];
if ($bloque->save()) {
Yii::app()->user->setFlash('success', 'Bloque ' . $bloque->titulo . ' guardado con éxito');
$this->redirect($_POST['returnUrl'] ? $_POST['returnUrl'] : $this->createUrl('pagina/view', array('id' => $bloque->pgBloques->pagina_id)));
}
}
//if(isset($_POST['Bloque']))
$this->render('modificar', array('model' => $bloque));
}
示例2: beforeDelete
protected function beforeDelete()
{
$this->transaccion = $this->dbConnection->getCurrentTransaction();
if ($this->transaccion === null) {
$this->transaccion = $this->dbConnection->beginTransaction();
}
try {
// 1. Desasignar de los micrositios que la tengan por defecto.
$micrositios = Micrositio::model()->findAllByAttributes(array('pagina_id' => $this->id));
foreach ($micrositios as $m) {
$m->pagina_id = NULL;
$m->save();
}
// 3.Verifico el tipo de página para ver si tiene una tabla auxiliar
$tabla = $this->tipoPagina->tabla;
$t = new $tabla();
$contenido = $t->findByAttributes(array('pagina_id' => $this->id));
switch ($tabla) {
case 'PgPrograma':
Horario::model()->deleteAllByAttributes(array('pg_programa_id' => $contenido->id));
break;
case 'PgDocumental':
FichaTecnica::model()->deleteAllByAttributes(array('pg_documental_id' => $contenido->id));
break;
/*case 'Carpeta':
Carpeta::model()->vaciar_carpeta( $contenido->id );
break;/**/
/*case 'Carpeta':
Carpeta::model()->vaciar_carpeta( $contenido->id );
break;/**/
case 'PgFiltro':
FiltroItem::model()->deleteAllByAttributes(array('pg_filtro_id' => $contenido->id));
break;
case 'PgBloques':
Bloque::model()->deleteAllByAttributes(array('pg_bloques_id' => $contenido->id));
break;
case 'PgEventos':
Evento::model()->deleteAllByAttributes(array('pg_eventos_id' => $contenido->id));
break;
}
// 4. Borro la tabla pg_
//$this->transaccion->commit();
return parent::beforeDelete();
} catch (Exception $e) {
$this->transaccion->rollback();
return false;
}
}