<tr > <td colspan="4" class="listbx_subhdng">In case of emergencies,<br /> contact : <?php $posts = Guardians::model()->findByAttributes(array('id' => $model->immediate_contact_id)); if (count($posts) == 0) { echo "No Guardians are added" . ' ' . CHtml::link('Add new', array('guardians/create&id=' . $model->id)); } else { echo $posts->first_name . ' ' . CHtml::link('Add new', array('guardians/create&id=' . $model->id)); } ?> </td> </tr> <tr class="table_listbxlast"> <td colspan="4" class="listbx_subhdng"><span class="subhdng_nrmal"> <?php $prev = StudentPreviousDatas::model()->findAllByAttributes(array('student_id' => $model->id)); if (count($prev) == 0) { echo "No Previous Datas"; } else { ?> (<?php echo CHtml::link('Add another Previous Data', array('studentPreviousDatas/create&id=' . $model->id)); ?> )</span> <?php } ?> </td> </tr> </table>
/** * 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 = StudentPreviousDatas::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }