• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Rating类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Rating的典型用法代码示例。如果您正苦于以下问题:PHP Rating类的具体用法?PHP Rating怎么用?PHP Rating使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Rating类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: starRating

 public function starRating($recipeId, $id = null, $value = null)
 {
     $session = Zend_Registry::get('session');
     $log = Zend_Registry::get('log');
     // fetch the rating
     $ra = new Rating();
     $rating = $ra->getRating($recipeId);
     // If were passing through a value we already know what to display and are probably read only
     if (isset($value)) {
         return $this->displayRating($value, $id);
     }
     // Logged in?
     if (!$session->user) {
         return $this->displayRating($rating);
     }
     //$log->debug( $session->user['name'] . ' is logged in' );
     $r = new Recipe();
     if ($r->isOwner($recipeId)) {
         return $this->displayRating($rating);
     }
     //$log->debug( $session->user['name'] . ' is not the owner' );
     // Has this user already rated?
     $db = Zend_Registry::get('db');
     $select = $db->select()->from('ratings', array("numberOfRatings" => "COUNT(*)"))->where("recipe_id = ?", $recipeId)->where("user_id = ?", $session->user['id']);
     //$log->debug( $select->__toString() );
     //$log->debug( $db->fetchOne( $select ) );
     // If we get a result show the user the overall rating
     if ($db->fetchOne($select) > 0) {
         return $this->displayRating($rating);
     }
     //$log->debug( $session->user['name'] . ' has not already rated this' );
     // Otherwise show the rating but make it clickable
     return $this->displayRating($rating, null, false);
 }
开发者ID:vishaleyes,项目名称:cookingwithzend,代码行数:34,代码来源:StarRating.php


示例2: addRate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function addRate($rating_score, $bus_Id)
 {
     $rateMod = new Rating();
     $rateMod->rating_score = $rating_score;
     $rateMod->product_id = $bus_Id;
     $rateMod->rating_type = 1;
     if ($rateMod->save()) {
         return $rateMod->rating_id;
     }
     return 0;
 }
开发者ID:indresh90,项目名称:utopeen_webpeoduct,代码行数:15,代码来源:ReviewController.php


示例3: getEntryArray

 public static function getEntryArray($query, $params)
 {
     list(, $result) = parent::executeQuery($query, self::RATING_COLUMNS, "", $params, -1);
     $entryArray = array();
     while ($post = $result->fetchObject()) {
         $ratingObj = new Rating($post->id, $post->rating);
         $rating = $post->rating / 2;
         $rating = str_format(localize("ratingword", $rating), $rating);
         array_push($entryArray, new Entry($rating, $ratingObj->getEntryId(), str_format(localize("bookword", $post->count), $post->count), "text", array(new LinkNavigation($ratingObj->getUri())), "", $post->count));
     }
     return $entryArray;
 }
开发者ID:leader716,项目名称:cops,代码行数:12,代码来源:rating.php


示例4: saveRating

 public function saveRating($params)
 {
     if (!is_array($params) || count($params) < 1) {
         return false;
     }
     $em = $this->getEntityManager();
     $rating = new Rating();
     $rating->setArticleId($params['article_id']);
     $rating->setStarRating($params['rating']);
     $rating->setCreatedOn(new \DateTime());
     $em->persist($rating);
     $em->flush();
     return true;
 }
开发者ID:hidaayah,项目名称:Symfony2-API,代码行数:14,代码来源:RatingRepository.php


示例5: getPartialUpdate

 public function getPartialUpdate(Rating $prior, Rating $fullPosterior, $updatePercentage)
 {
     $priorGaussian = new GaussianDistribution($prior->getMean(), $prior->getStandardDeviation());
     $posteriorGaussian = new GaussianDistribution($fullPosterior->getMean(), $fullPosterior . getStandardDeviation());
     // From a clarification email from Ralf Herbrich:
     // "the idea is to compute a linear interpolation between the prior and posterior skills of each player
     //  ... in the canonical space of parameters"
     $precisionDifference = $posteriorGaussian->getPrecision() - $priorGaussian->getPrecision();
     $partialPrecisionDifference = $updatePercentage * $precisionDifference;
     $precisionMeanDifference = $posteriorGaussian->getPrecisionMean() - $priorGaussian . getPrecisionMean();
     $partialPrecisionMeanDifference = $updatePercentage * $precisionMeanDifference;
     $partialPosteriorGaussion = GaussianDistribution::fromPrecisionMean($priorGaussian->getPrecisionMean() + $partialPrecisionMeanDifference, $priorGaussian->getPrecision() + $partialPrecisionDifference);
     return new Rating($partialPosteriorGaussion->getMean(), $partialPosteriorGaussion->getStandardDeviation(), $prior->_conservativeStandardDeviationMultiplier);
 }
开发者ID:modulexcite,项目名称:PHPSkills,代码行数:14,代码来源:Rating.php


示例6: calculateNewRating

 /**
  * This is the function processing described in step 5 of Glickman's paper.
  *
  * @param Rating $player
  * @param array  $results
  */
 protected function calculateNewRating(Rating $player, array $results)
 {
     $phi = $player->getGlicko2RatingDeviation();
     $sigma = $player->getVolatility();
     $a = log(pow($sigma, 2));
     $delta = $this->delta($player, $results);
     $v = $this->v($player, $results);
     // step 5.2 - set the initial values of the iterative algorithm to come in step 5.4
     $A = $a;
     $B = 0;
     if (pow($delta, 2) > pow($phi, 2) + $v) {
         $B = log(pow($delta, 2) - pow($phi, 2) - $v);
     } else {
         $k = 1;
         $B = $a - $k * abs($this->tau);
         while ($this->f($B, $delta, $phi, $v, $a, $this->tau) < 0) {
             $k++;
             $B = $a - $k * abs($this->tau);
         }
     }
     // step 5.3
     $fA = $this->f($A, $delta, $phi, $v, $a, $this->tau);
     $fB = $this->f($B, $delta, $phi, $v, $a, $this->tau);
     // step 5.4
     while (abs($B - $A) > self::CONVERGENCE_TOLERANCE) {
         $C = $A + ($A - $B) * $fA / ($fB - $fA);
         $fC = $this->f($C, $delta, $phi, $v, $a, $this->tau);
         if ($fC * $fB < 0) {
             $A = $B;
             $fA = $fB;
         } else {
             $fA = $fA / 2;
         }
         $B = $C;
         $fB = $fC;
     }
     $newSigma = exp($A / 2);
     $player->setWorkingVolatility($newSigma);
     // Step 6
     $phiStar = $this->calculateNewRatingDeviation($phi, $newSigma);
     // Step 7
     $newPhi = 1 / sqrt(1 / pow($phiStar, 2) + 1 / $v);
     // note that the newly calculated rating values are stored in a "working" area in the Rating object
     // this avoids us attempting to calculate subsequent participants' ratings against a moving target
     $player->setWorkingRating($player->getGlicko2Rating() + pow($newPhi, 2) * $this->outcomeBasedRating($player, $results));
     $player->setWorkingRatingDeviation($newPhi);
     $player->incrementNumberOfResults(count($results));
 }
开发者ID:maartenstaa,项目名称:glicko2,代码行数:54,代码来源:RatingCalculator.php


示例7: getIndex

 public function getIndex()
 {
     $rating = new Rating();
     $rating = Rating::where('ven_id', '=', '14')->avg('rvalue');
     echo $rating;
     //return 'Ratings';
 }
开发者ID:abaecor,项目名称:funfest,代码行数:7,代码来源:RatingsController.php


示例8: get

 public function get($id)
 {
     $doctor = Doctor::with(['companions', 'episodes'])->find($id);
     $ratings = Rating::getRating('doctor', $id);
     $comments = Comment::where('item_id', $id)->where('item_type', 'doctor')->with('user')->orderBy('created_at', 'desc')->get();
     return View::make('items.doctor', ['doctor' => $doctor, 'ratings' => $ratings, 'comments' => $comments]);
 }
开发者ID:thechrisroberts,项目名称:thedoctor,代码行数:7,代码来源:DoctorController.php


示例9: deleteLike

 public static function deleteLike($rating_id)
 {
     $error_code = ApiResponse::OK;
     $user_id = Session::get('user_id');
     if (Rating::where('id', $rating_id)->first()) {
         $like = Like::where('rating_id', $rating_id)->where('user_id', $user_id)->first();
         if ($like) {
             //update like_count on rating
             $like_rating = Rating::where('id', $like->rating_id)->first();
             if ($like_rating != null) {
                 $like_rating->like_count = $like_rating->like_count - 1;
                 $like_rating->save();
             }
             $like->delete();
             $data = 'Like deleted';
         } else {
             $error_code = ApiResponse::NOT_EXISTED_LIKE;
             $data = ApiResponse::getErrorContent(ApiResponse::NOT_EXISTED_LIKE);
         }
     } else {
         $error_code = ApiResponse::UNAVAILABLE_RATING;
         $data = ApiResponse::getErrorContent(ApiResponse::UNAVAILABLE_RATING);
     }
     return array("code" => $error_code, "data" => $data);
 }
开发者ID:anht37,项目名称:winelover_server,代码行数:25,代码来源:Like.php


示例10: get

 public function get($season, $episode)
 {
     $episode = Episode::with(['doctors', 'companions', 'enemies'])->where('season', $season)->where('episode', $episode)->first();
     $ratings = Rating::getRating('episode', $episode->id);
     $comments = Comment::where('item_id', $episode->id)->where('item_type', 'episode')->with('user')->orderBy('created_at', 'desc')->get();
     return View::make('items.episode', ['episode' => $episode, 'ratings' => $ratings, 'comments' => $comments]);
 }
开发者ID:thechrisroberts,项目名称:thedoctor,代码行数:7,代码来源:EpisodeController.php


示例11: get

 public function get($id)
 {
     $enemy = Enemy::with('episodes')->find($id);
     $ratings = Rating::getRating('enemy', $id);
     $comments = Comment::where('item_id', $id)->where('item_type', 'enemy')->with('user')->orderBy('created_at', 'desc')->get();
     return View::make('items.enemy', ['enemy' => $enemy, 'ratings' => $ratings, 'comments' => $comments]);
 }
开发者ID:thechrisroberts,项目名称:thedoctor,代码行数:7,代码来源:EnemyController.php


示例12: show_vars

 public static function show_vars(&$vars, $id)
 {
     $vars['ratings'] = array();
     foreach (Rating::find_by('user_id', $id) as $k => $v) {
         $vars['ratings'][] = array('rating' => $v, 'beer' => Beer::find($v->beer_id));
     }
 }
开发者ID:Rochet2,项目名称:Tsoha-Bootstrap,代码行数:7,代码来源:user_controller.php


示例13: testGetRatingDetailSuccess

 public function testGetRatingDetailSuccess()
 {
     $this->setUpRating();
     $response = $this->call('GET', 'api/rating/1');
     $rating_infor = Rating::where('id', 1)->with('wine')->first();
     $this->assertEquals(array("code" => ApiResponse::OK, "data" => $rating_infor->toArray()), json_decode($response->getContent(), true));
 }
开发者ID:anht37,项目名称:winelover_server,代码行数:7,代码来源:GetRatingMyWineTest.php


示例14: can_edit

 public static function can_edit($id)
 {
     $v = Rating::find($id);
     if ($v && static::is_logged_user($v->user_id)) {
         return true;
     }
     return false;
 }
开发者ID:Rochet2,项目名称:Tsoha-Bootstrap,代码行数:8,代码来源:rating_controller.php


示例15: getByUser

		public static function getByUser($id)
		{
			global $db;
			$ratingSQL = "SELECT * FROM ratings WHERE userid=?";
			$values = array($id);
			$ratings = $db->qwv($ratingSQL, $values);
			
			return Rating::wrap($ratings);
		}
开发者ID:nickparker88,项目名称:capstone,代码行数:9,代码来源:Rating.php


示例16: executeRate

 public function executeRate()
 {
     $params = explode('.', $this->getRequestParameter('object_id'));
     $type = $params[0];
     $object_id = $params[1];
     $value = $this->getRequestParameter('value');
     $rating = null;
     if ($type == Rating::APPLICATION) {
         $object = Doctrine::getTable('Application')->find($object_id);
         $q = new Doctrine_Query();
         $rating = $q->select('r.*')->from('Rating r')->where('application_id = ? and user_id = ?', array($object_id, $this->getUser()->getId()))->fetchOne();
         if (!$rating) {
             $rating = new Rating();
             $rating->setUserId($this->getUser()->getId());
             $rating->setApplicationId($object_id);
         }
     } elseif ($type == Rating::MODULE) {
         $object = Doctrine::getTable('Madule')->find($object_id);
         $q = new Doctrine_Query();
         $rating = $q->select('r.*')->from('Rating r')->where('madule_id = ? and user_id = ?', array($object_id, $this->getUser()->getId()))->fetchOne();
         if (!$rating) {
             $rating = new Rating();
             $rating->setUserId($this->getUser()->getId());
             $rating->setMaduleId($object_id);
         }
     } elseif ($type == Rating::THEME) {
         $object = Doctrine::getTable('Theme')->find($object_id);
         $q = new Doctrine_Query();
         $rating = $q->select('r.*')->from('Rating r')->where('theme_id = ? and user_id = ?', array($object_id, $this->getUser()->getId()))->fetchOne();
         if (!$rating) {
             $rating = new Rating();
             $rating->setUserId($this->getUser()->getId());
             $rating->setThemeId($object_id);
         }
     }
     $this->forward404Unless($value <= 5);
     $this->forward404Unless($value >= 1);
     if ($rating) {
         $rating->setValue($value);
         $rating->save();
         $this->my_rating = $value;
         $this->rating = $object->getRating();
     }
 }
开发者ID:amitesh-singh,项目名称:Enlightenment,代码行数:44,代码来源:actions.class.php


示例17: testCreateRatingSuccess

 public function testCreateRatingSuccess()
 {
     $_params = $this->_params;
     $_params['user_id'] = $this->_user_id;
     $response = $this->_getAuth($_params);
     //get created login information
     $rating_infor = Rating::get(array('user_id', 'wine_unique_id', 'rate', 'comment_count', 'like_count', 'is_my_wine', 'updated_at', 'created_at', 'id'))->last();
     $this->assertNotNull($rating_infor);
     $this->assertEquals(array("code" => ApiResponse::OK, "data" => $rating_infor->toArray()), json_decode($response->getContent(), true));
 }
开发者ID:anht37,项目名称:winelover_server,代码行数:10,代码来源:CreateRatingTest.php


示例18: delete

 /**
  * Override delete method
  * Delete topic itself and all it's comments, ratings, and view counter
  */
 public function delete()
 {
     $tid = $this->id;
     // delete view counter
     Counter::where("[entityId] = ? AND [entityTypeId] = ?", [$tid, Topic::ENTITY_TYPE])->delete();
     Rating::where("[entityId] = ? AND [entityType] = ?", [$tid, Topic::ENTITY_TYPE])->delete();
     RatingStatistic::where("[entityId] = ? AND [entityType] = ?", [$tid, Topic::ENTITY_TYPE])->delete();
     Comment::where("[topicId] = ?", $tid)->delete();
     parent::delete();
 }
开发者ID:a4501150,项目名称:FDUGroup,代码行数:14,代码来源:Topic.php


示例19: testUpdateRatingSuccess

 public function testUpdateRatingSuccess()
 {
     $this->setUpRating();
     $_params = $this->_params;
     //dd(json_encode($_params));
     $response = $this->action('POST', 'RatingController@update', array('id' => 1), array('data' => json_encode($_params), '_method' => 'PUT'));
     //get created login information
     $rating_infor = Rating::where('id', 1)->first();
     $this->assertEquals(array("code" => ApiResponse::OK, "data" => $rating_infor->toArray()), json_decode($response->getContent(), true));
 }
开发者ID:anht37,项目名称:winelover_server,代码行数:10,代码来源:UpdateRatingTest.php


示例20: showIndexJson

 public function showIndexJson()
 {
     // $parking_lots = ParkingLot::all();
     $lots_array = [];
     $parking_lots = DB::table('parking_lots')->select('id', 'name', 'lat', 'lng', 'address', 'price', 'max_spots')->get();
     // $ratings = new RatingsController();
     $parking_lots = Rating::ratingOrder($parking_lots);
     Log::info($parking_lots);
     return Response::json($parking_lots);
 }
开发者ID:Park-It,项目名称:parkit.dev,代码行数:10,代码来源:HomeController.php



注:本文中的Rating类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ReCaptcha类代码示例发布时间:2022-05-23
下一篇:
PHP Rank类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap