public function actionIndex() { $id = Yii::app()->user->getId(); if (empty($id)) { $this->redirect(Yii::app()->user->returnUrl . 'site/login'); } $criteria = new CDbCriteria(); $criteria->condition = 'ID_USERS = ' . $id; $criteria->order = 'ID_GALLERY_PRIBADI DESC'; $gallery = GalleryPribadi::model()->findAll($criteria); $gallery_barang = GalleryBarang::model()->get_data_barang($id); $user = Users::model()->findByPk($id); // $criteria2 = new CDbCriteria(); // $criteria->condition = 'ID_USERS = '.$id; // $criteria->order = 'ID_GALLERY_BARANG DESC'; // $gallery = GalleryBarang::model()->findAll($criteria); if (isset($_POST['Users'])) { $rnd = rand(0, 9999); // generate random number between 0-9999 $user->attributes = $_POST['Users']; $uploadedFile = CUploadedFile::getInstance($user, 'FOTO'); $fileName = "{$rnd}-{$uploadedFile}"; // random number + file name $user->FOTO = $fileName; $user->save(); $uploadedFile->saveAs(Yii::app()->basePath . '/../images/profile/' . $fileName); $this->redirect(Yii::app()->user->returnUrl . 'profile'); } $profile = TransaksiRegistrasi::model()->get_data_profile($id); // print_r($profile); die(); $this->render('profile', array('model' => $user, 'data' => $profile, 'gallery' => $gallery, 'koleksi' => $gallery_barang)); }
/** * 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 GalleryPribadi the loaded model * @throws CHttpException */ public function loadModel($id) { $model = GalleryPribadi::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }