public function actionLookup2() { $term = $_GET['term']; if (isset($_GET['term'])) { $users = DataPenelitian::model()->findAll(array('condition' => 'judul LIKE :judul', 'params' => array(':judul' => "%{$term}%"))); $return = array(); $i = 0; foreach ($users as $user) { $return[$i] = $user->judul; $i++; } } echo CJSON::encode($return); }
/** * 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 DataPenelitian the loaded model * @throws CHttpException */ public function loadModel($id) { $model = DataPenelitian::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php /* @var $this DataPenelitianController */ /* @var $model DataPenelitian */ $this->breadcrumbs = array('Daftar Paper' => array('index'), $model->id); //$post = DataPenelitian::model()->findByPk(Yii::app()->request->getParam('id')); //echo($post['creater']); $user_updater = ''; $post = DataPenelitian::model()->findByPk(Yii::app()->request->getParam('id')); if (Yii::app()->user->getId() === $post['creater']) { $user_updater = Yii::app()->user->name; } $this->menu = array(array('label' => 'Daftar Paper', 'url' => array('index')), array('label' => 'Tambah Paper', 'url' => array('create')), array('label' => 'Perbaharui Paper', 'url' => array('update', 'id' => $model->id), 'visible' => Yii::app()->user->getName() == $user_updater), array('url' => array('admin'), 'label' => 'Atur Paper', 'visible' => Yii::app()->getModule('user')->isAdmin())); ?> <h1>Lihat Paper #<?php echo $model->id; ?> </h1> <?php $this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'judul', 'peneliti', 'tahun_publikasi', 'masalah', 'deskripsi_masalah', 'keyword', 'domain_data', 'deskripsi_domain_data', 'metode', 'deskripsi_metode', 'hasil')));