当前位置: 首页>>代码示例>>PHP>>正文


PHP Match::getQueryBuilder方法代码示例

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


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

示例1: recalculate

 /**
  * Recalculates match history for all teams and matches
  *
  * Recalculation is done as follows:
  * 1. A match is chosen as a starting point - it's stored old team ELOs are
  *    considered correct
  * 2. Team ELOs are reset to their values at the starting point
  * 3. Each match that occurred since the first specified match has its ELO
  *    recalculated based on the current team values, and the new match data
  *    and team ELOs are stored in the database
  *
  * @param Match $match The first match
  */
 private function recalculate(Match $match)
 {
     try {
         // Commented out to prevent ridiculously large recalculations
         //set_time_limit(0);
         $query = Match::getQueryBuilder()->where('status')->notEquals('deleted')->where('type')->equals(Match::OFFICIAL)->where('time')->isAfter($match->getTimestamp(), $inclusive = true)->sortBy('time');
         /** @var Match[] $matches */
         $matches = $query->getModels($fast = true);
         // Send the total count to client-side javascript
         $this->log(count($matches) . "\n");
         // Start a transaction so tables are locked and we don't stay with
         // messed up data if something goes wrong
         Database::getInstance()->startTransaction();
         $teamsReset = [];
         // Reset match teams, in case the selected match is deleted and does
         // not show up in the list of matches to recalculate
         $match->getTeamA()->setElo($match->getTeamAEloOld());
         $match->getTeamB()->setElo($match->getTeamBEloOld());
         $teamsReset[$match->getTeamA()->getId()] = true;
         $teamsReset[$match->getTeamB()->getId()] = true;
         foreach ($matches as $i => $match) {
             // Reset teams' ELOs if they haven't been reset already
             if (!isset($teamsReset[$match->getTeamA()->getId()])) {
                 $teamsReset[$match->getTeamA()->getId()] = true;
                 $match->getTeamA()->setElo($match->getTeamAEloOld());
             }
             if (!isset($teamsReset[$match->getTeamB()->getId()])) {
                 $teamsReset[$match->getTeamB()->getId()] = true;
                 $match->getTeamB()->setElo($match->getTeamBEloOld());
             }
             $match->recalculateElo();
             // Send an update to the client-side javascript, so that a
             // progress bar can be updated
             $this->log("m");
         }
     } catch (Exception $e) {
         Database::getInstance()->rollback();
         Database::getInstance()->finishTransaction();
         throw $e;
     }
     Database::getInstance()->finishTransaction();
     $this->log("\n\nCalculation successful\n");
 }
开发者ID:allejo,项目名称:bzion,代码行数:56,代码来源:MatchController.php

示例2: isLastMatch

 /**
  * Find if a specific match is the team's last one
  *
  * @param  int|Match $match The match
  * @return bool
  */
 public function isLastMatch($match)
 {
     // Find if this team participated in any matches after the current match
     return !Match::getQueryBuilder()->with($this)->where('status')->notEquals('deleted')->where('time')->isAfter(Match::get($match)->getTimestamp())->any();
 }
开发者ID:allejo,项目名称:bzion,代码行数:11,代码来源:Team.php

示例3: getMatchActivity

 /**
  * Get the match activity in matches per day for a player
  *
  * @return float
  */
 public function getMatchActivity()
 {
     $activity = 0.0;
     $matches = Match::getQueryBuilder()->active()->with($this)->where('time')->isAfter(TimeDate::from('45 days ago'))->getModels($fast = true);
     foreach ($matches as $match) {
         $activity += $match->getActivity();
     }
     return $activity;
 }
开发者ID:allejo,项目名称:bzion,代码行数:14,代码来源:Player.php

示例4: isLastMatch

 /**
  * Find if a specific match is the team's last one
  *
  * @param  int  $matchID The ID of the match
  * @return bool
  */
 public function isLastMatch($matchID)
 {
     // Find if this team participated in any matches after the current match
     return !Match::getQueryBuilder()->with($this)->active()->sortBy('id')->reverse()->startAt($matchID)->any();
 }
开发者ID:bchhun,项目名称:bzion,代码行数:11,代码来源:Team.php

示例5: countMatches

 /**
  * Get the number of matches played on this map
  *
  * @return int
  */
 public function countMatches()
 {
     return Match::getQueryBuilder()->active()->where('map')->is($this)->count();
 }
开发者ID:allejo,项目名称:bzion,代码行数:9,代码来源:Map.php


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