Exemple #1
0
 public function actionRating()
 {
     if (!($rating = MovieRating::model()->find('movie_id=:movie_id AND user_id=:user_id', array(':movie_id' => CHttpRequest::getPost('id'), ':user_id' => Yii::app()->user->id)))) {
         $rating = new MovieRating();
         $rating->movie_id = CHttpRequest::getPost('id');
         $rating->user_id = Yii::app()->user->id;
     }
     $rating->value = CHttpRequest::getPost('rate');
     $rating->save();
     var_dump($rating);
 }
Exemple #2
0
 public function getMyRating()
 {
     //     static $_rating;
     //     if(!$_rating)
     $_rating = MovieRating::model()->find('movie_id=:movie_id AND user_id=:user_id', array(':movie_id' => $this->id, ':user_id' => Yii::app()->user->id));
     return $_rating ? $_rating->value : null;
 }