/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Url the loaded model * @throws CHttpException */ public function loadModel($id) { $model = RedSocial::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
protected function beforeDelete() { $this->transaccion = $this->dbConnection->getCurrentTransaction(); if ($this->transaccion === null) { $this->transaccion = $this->dbConnection->beginTransaction(); } try { $this->pagina_id = NULL; $this->save(NULL); foreach ($this->paginas as $pagina) { $p = Pagina::model()->findByPk($pagina->id); $p->delete(); } foreach ($this->albumFotos as $albumFoto) { $af = AlbumFoto::model()->findByPk($albumFoto->id); $af->delete(); } foreach ($this->albumVideos as $albumVideo) { $av = AlbumVideo::model()->findByPk($albumVideo->id); $av->delete(); } foreach ($this->programacions as $programacion) { $pr = Programacion::model()->findByPk($programacion->id); $pr->delete(); } foreach ($this->redSocials as $redSocial) { $r = RedSocial::model()->findByPk($redSocial->id); $r->delete(); } return parent::beforeDelete(); } catch (Exception $e) { $this->transaccion->rollback(); return false; } }