/**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     /* @var $professor Professor */
     $professor = Professor::model()->findByPk($id);
     // Gerando lista de depoimentos
     $c = new CDbCriteria();
     $c->compare('aprovado', 1);
     $c->compare('id_professor', $professor->id_professor);
     $c->order = "up DESC, down ASC, id_depoimento DESC";
     $depoimentos = Depoimento::model()->findAll($c);
     // Buscando nota do professor
     $mediaVotos = floor(Voto::model()->model()->findBySql("SELECT AVG(voto) as voto FROM voto WHERE id_professor = '{$professor->id_professor}'")->attributes['voto'] * 100) / 100;
     $qtdVotos = Voto::model()->countByAttributes(array('id_professor' => $professor->id_professor));
     // Buscando as disciplinas
     $ensina = ProfessorDisciplina::model()->findAllByAttributes(array('id_professor' => $professor->id_professor));
     $this->render('view', array('professor' => $professor, 'depoimentos' => $depoimentos, 'ensina' => $ensina, 'media' => $mediaVotos, 'qtdVotos' => $qtdVotos));
 }
<?php 
$i = 0;
if (count($professores) == 0) {
    echo "<div class='alert'><b><h4>Nenhum professor encontrado.</h4></b></div>";
}
foreach ($professores as $key => $professor) {
    ?>
		<?php 
    if ($i == 0) {
        ?>
			<div class="span12">
		<?php 
    }
    ?>

		<?php 
    $depoimentosMaisRelevante = Depoimento::model()->findByAttributes(array('id_professor' => $professor->id_professor), array('order' => 'up DESC'));
    $mediaVotos = floor(Voto::model()->model()->findBySql("SELECT AVG(voto) as voto FROM voto WHERE id_professor = '{$professor->id_professor}'")->attributes['voto'] * 100) / 100;
    $this->renderPartial('pesquisa_view', array('professor' => $professor, 'depoimento' => $depoimentosMaisRelevante, 'media' => $mediaVotos));
    ?>
	<?php 
    if ($i == 1) {
        $i = -1;
        ?>
			</div>
		<?php 
    }
    ?>
	<?php 
    $i++;
}
 /**
  * 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 Depoimento the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Depoimento::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }