/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { /* $this->render('view',array( 'model'=>$this->loadModel($id), )); */ $opcion = Opciones::model()->findAll("`encuestas_IdEncuesta` = {$id}"); $this->render('view', array('opcion' => $opcion, 'model' => $this->loadModel($id))); }
$numero_aleatorio = rand(1, 500); $publicidades = Publicidades::model()->findAll("`idPublicidad` = {$numero_aleatorio}"); if ($publicidades == Null) { $i--; } else { foreach ($publicidades as $data) { if ($i == 2) { ?> <div style="position: static; margin-top: 5px; background-color: white"> <p> <?php $encuesta = Encuestas::model()->findAll(array('order' => 'idEncuesta DESC', 'limit' => 1)); foreach ($encuesta as $dataE) { echo $dataE->pregunta; $_SESSION['idEncuesta'] = $dataE->idEncuesta; $opciones = Opciones::model()->findAll(array('order' => 'idOpcion DESC', 'condition' => "`encuestas_idEncuesta` = {$dataE->idEncuesta}")); ?> <ul><?php foreach ($opciones as $dataO) { ?> <li><?php echo $dataO->opcion; if (!isset($_SESSION)) { session_start(); } else { if (!isset($_SESSION['vot'])) { $_SESSION['vot'] = 0; echo CHtml::button('+', array('submit' => 'index.php?r=opciones/update&id=' . $dataO->idOpcion, 'style' => "position: absolute; right: 15px;")); } else { if ($_SESSION['vot'] == 1) { echo " - Votos: ";
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = Opciones::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'La página solicitada no existe.'); } return $model; }