Пример #1
0
 /**
  * Insert tennis matches into some key redis
  * @param array $matchInfo
  * @return boolean
  * @author QuangTM
  */
 public function insertTennisMatches($matchInfo)
 {
     try {
         // Get redis instance
         $redisInstance = Thethao_Global::getRedis('object');
         // Get key redis for adding match by team
         $keyTennisMatches = vsprintf($this->_tennis_matches, '');
         $keyTennisPlayerMatches = vsprintf($this->_tennis_player_matches, '');
         $keyTennisPlayer1a = $keyTennisPlayerMatches . $matchInfo['player1a'];
         $keyTennisPlayer2a = $keyTennisPlayerMatches . $matchInfo['player2a'];
         $keyTennisPlayer1b = $matchInfo['player1b'] != 0 ? $keyTennisPlayerMatches . $matchInfo['player1b'] : NULL;
         $keyTennisPlayer2b = $matchInfo['player2b'] != 0 ? $keyTennisPlayerMatches . $matchInfo['player2b'] : NULL;
         // Add multi tasks for redis
         $redisInstance->zRem($keyTennisMatches, $matchInfo['match_id']);
         $redisInstance->zAdd($keyTennisMatches, $matchInfo['datetime_happen'], $matchInfo['match_id']);
         $redisInstance->zRem($keyTennisPlayer1a, $matchInfo['match_id']);
         $redisInstance->zAdd($keyTennisPlayer1a, $matchInfo['datetime_happen'], $matchInfo['match_id']);
         $redisInstance->zRem($keyTennisPlayer2a, $matchInfo['match_id']);
         $redisInstance->zAdd($keyTennisPlayer2a, $matchInfo['datetime_happen'], $matchInfo['match_id']);
         if ($keyTennisPlayer1b != NULL && $keyTennisPlayer2b != NULL) {
             $redisInstance->zRem($keyTennisPlayer1b, $matchInfo['match_id']);
             $redisInstance->zAdd($keyTennisPlayer1b, $matchInfo['datetime_happen'], $matchInfo['match_id']);
             $redisInstance->zRem($keyTennisPlayer2b, $matchInfo['match_id']);
             $redisInstance->zAdd($keyTennisPlayer2b, $matchInfo['datetime_happen'], $matchInfo['match_id']);
         }
         // Execute
         $redisInstance->exec();
         return TRUE;
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex);
     }
 }
Пример #2
0
 /**
  * Get list league and season by team attend
  * @param int $teamID
  * @return array|boolean
  * @author QuangTM
  */
 public function getListLeagueAndSeasonTeamAttend($teamID)
 {
     $result = array();
     try {
         // Get redis instance
         $redisInstance = Thethao_Global::getRedis('article');
         // Get key cache
         $pattern = vsprintf($this->_team_match_league, array($teamID, '*'));
         // Get array key
         $arrKeys = $redisInstance->keys($pattern);
         // Pattern for get league
         $pattern = '/' . str_replace('*', '(\\d+)', $pattern) . '/';
         $match = null;
         foreach ($arrKeys as $key) {
             if (preg_match($pattern, $key, $match)) {
                 $result[$match[1]] = $redisInstance->sMembers($key);
             }
         }
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex);
     }
     return $result;
 }
Пример #3
0
 public function tinTucTayVotAction()
 {
     try {
         //Set param
         $this->_request->setParam('block_cate', SITE_ID);
         //get params
         $params = $this->_request->getParams();
         $player_id = $params['id'] ? $params['id'] : NULL;
         $intPage = $params['page'] ? $params['page'] : 1;
         $title = $params[2] ? $params[2] : '';
         $canContinue = FALSE;
         //Set start offset
         $perpage = LIMIT_NEW_MORE;
         $intStart = ($intPage - 1) * $perpage;
         if ($player_id >= 0) {
             //get Object's instance
             $tennisObj = $this->view->objObject->getTennis();
             $tennisObj->setId($player_id);
             //get detail player tennis
             $playerDetail = $tennisObj->getDetailObjectBasic($player_id);
             if (is_array($playerDetail) && !empty($playerDetail)) {
                 $seoName = Fpt_Filter::setSeoLink($playerDetail['name']);
                 if ($title === $seoName) {
                     //get News's instance
                     $newsModel = $this->view->objArticle;
                     //init param get news of playser
                     $arrParam = array('object_id' => $player_id, 'object_type' => OBJECT_TYPE_TENNIS, 'limit' => $perpage, 'offset' => $intStart);
                     $arrListIDNews = $newsModel->getObjectNews($arrParam);
                     //Get List ID ArticleID
                     $intTotal = isset($arrListIDNews['total']) ? intval($arrListIDNews['total']) : 0;
                     //Check Data
                     if (!empty($arrListIDNews['data'])) {
                         $newsModel->setIdBasic($arrListIDNews['data']);
                         //get Instance Block
                         $objBlock = Thethao_Plugin_Block::getInstance();
                         //set exclude article id from $arrListIDNews
                         $objBlock->setExclude($arrListIDNews['data']);
                     }
                     //InitParam Paging
                     $strUri = '/tin-tuc-tay-vot/' . $seoName . '-' . $player_id;
                     $arrParamPaging = array('total' => $intTotal, 'page' => $intPage, 'uri' => $strUri, 'showItem' => 3, 'perpage' => $perpage, 'idPagination' => 'pagination', 'extEnd' => '.html', 'separate' => '-');
                     //Head title
                     $this->view->headTitle("Tin tức tay vợt - " . $playerDetail['name_format']);
                     //Head meta data
                     $this->view->headMeta()->appendName('description', "Tin tức tay vợt - " . $playerDetail['name_format']);
                     /* Assign to view */
                     $this->view->assign(array('limit' => LIMIT_NEW_MORE, 'arrDataNews' => $arrListIDNews['data'], 'arrParamPaging' => $arrParamPaging, 'intCategoryId' => SITE_ID, 'intArticleId' => SITE_ID));
                     $canContinue = true;
                 } else {
                     $this->_redirect('/tin-tuc-tay-vot/' . $seoName . '-' . $player_id . '-' . $intPage . '.html');
                 }
             }
         }
         if ($canContinue != true) {
             $this->_redirect('/error');
             exit;
         }
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex);
     }
 }
Пример #4
0
 /**
  * rewrite player champion
  * @param type $seasonId
  * @return array|boolean
  * @author PhongTX
  */
 public function rewritePlayerChampion($seasonId)
 {
     try {
         $keyCache = vsprintf($this->_player_champion_by_season, array($seasonId));
         //Delete memcache
         Thethao_Global::deleteMemcache(array($keyCache));
         $this->getListTopPlayers($seasonId);
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex, 1);
     }
 }
Пример #5
0
 /**
  * Get list statistics of tennis player by array player id
  * @param array $arrPlayerIDs
  * @return array|boolean
  * @author QuangTM
  */
 public function getTennisPlayerStatsByPlayerIDs($arrPlayerIDs)
 {
     // Set result
     $result = array();
     try {
         if (!is_array($arrPlayerIDs) || !count($arrPlayerIDs)) {
             return FALSE;
         }
         // Get DB Obj
         $dbObj = Thethao_Global::getDB('sport', 'slave');
         // Prepare SQL
         $stmt = $dbObj->prepare('CALL sp_tennis_getPlayerStat(:p_playerid);');
         // Bind param
         $stmt->bindParam('p_playerid', implode(',', $arrPlayerIDs), PDO::PARAM_STR);
         // Execute
         $stmt->execute();
         while ($row = $stmt->fetch()) {
             if (!isset($result[$row['playerid']])) {
                 $result[$row['playerid']] = array();
             }
             array_push($result[$row['playerid']], $row);
         }
         // Close
         $stmt->closeCursor();
         // Release variables
         unset($stmt);
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex, 1);
     }
     return $result;
 }
Пример #6
0
 /**
  * push job insert match predict
  * @param array $params
  * @return boolean
  * @author PhuongTN
  */
 public function pushJobInsertMatchPredict($params)
 {
     try {
         $result = array('result' => false);
         $config = Thethao_Global::getApplicationIni();
         //Create job client
         $jobClient = Thethao_Global::getJobClientInstance('sport');
         //get job func name
         $jobFunc = $config['job']['task']['sport']['match_predict'];
         //default
         $jobParams = array();
         //add job class name
         $jobParams['class'] = 'Job_Thethao_JobBackendCache';
         //reg func delete article
         $jobParams['function'] = 'insertMatchPredict';
         //init array args
         $jobParams['args'] = $params;
         //Register job with normal priority
         $pushJob = $jobClient->doBackgroundTask($jobFunc, $jobParams);
         $pushJob = $jobClient->doBackgroundTask($jobFunc . '_new', $jobParams);
         if ($pushJob != false) {
             $result['result'] = true;
         }
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex);
     }
     return $result;
 }
Пример #7
0
 /**
  * Get list league and season by team attend
  * @param int $teamID
  * @return array|boolean
  * @author QuangTM
  */
 public function getListLeagueAndSeasonTeamAttend($teamID)
 {
     // Default result
     $result = array();
     try {
         // Get DB Obj
         $dbObj = Thethao_Global::getDB('sport', 'slave');
         // Prepare SQL
         $stmt = $dbObj->prepare('CALL sp_sport_getLeagueSeasonByTeam(:p_teamid);');
         // Bind param
         $stmt->bindParam('p_teamid', $teamID, PDO::PARAM_INT);
         // Execute
         $stmt->execute();
         while ($row = $stmt->fetch()) {
             if (!isset($result[$row['league_id']])) {
                 $result[$row['league_id']] = array();
             }
             array_push($result[$row['league_id']], $row['season_id']);
         }
         // Close cursor
         $stmt->closeCursor();
         // Release
         unset($stmt);
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex, 1);
     }
     // Return result
     return $result;
 }
Пример #8
0
 /**
  * Get list players by team
  * @param int $teamId
  * @return array
  * @author ThuyNT
  */
 public function getListPlayersByTeam($teamId)
 {
     try {
         // Get DB Obj
         $dbObj = Thethao_Global::getDB('sport', 'slave');
         // Prepare SQL
         $stmt = $dbObj->prepare('CALL sp_getListPlayersByTeam(:p_teamid);');
         // Bind param
         $stmt->bindParam('p_teamid', $teamId, PDO::PARAM_INT);
         // Execute
         $stmt->execute();
         // Get result
         $result = array();
         while ($row = $stmt->fetch()) {
             $result[] = $row['player_id'];
         }
         // Close
         $stmt->closeCursor();
         // Release variables
         unset($stmt);
         return $result;
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex, 1);
     }
 }
Пример #9
0
 /**
  * Get list league by group
  * @param int $group
  * @return array
  */
 public function getListLeagueByGroup($group)
 {
     $memcacheInstance = Thethao_Global::getCache();
     $keyCache = vsprintf($this->_league_by_group_list, array($group));
     // Read cache
     $listLeagues = $memcacheInstance->read($keyCache);
     // Miss cache
     if ($listLeagues === FALSE) {
         try {
             $config = Thethao_Global::getApplicationIni();
             // Get db teamseason instance
             $leagueObj = $this->factory('Football', $config['database']['default']['adapter']);
             // Get data from db
             $listLeagues = $leagueObj->getListLeagueByGroup($group);
             // Write to cache
             $memcacheInstance->write($keyCache, $listLeagues);
             Thethao_Global::writeMemcache($keyCache, $listLeagues);
         } catch (Exception $ex) {
             Thethao_Global::sendlog($ex);
         }
     }
     return $listLeagues;
 }
Пример #10
0
 /**
  * Delete match in league by league id and match id
  * @param type $leagueId
  * @param type $matchId
  */
 public function deleteMatchByLeague($leagueId, $matchId)
 {
     try {
         // Get redis instance
         $redisInstance = Thethao_Global::getRedis('object');
         // Get key redis for adding match by league
         $keyCache = sprintf($this->_league_match, $leagueId);
         $redisInstance->zAdd($keyCache, -1, $matchId);
         return $redisInstance->zDelete($keyCache, $matchId);
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex);
         return false;
     }
 }
Пример #11
0
 /**
  * Get list league by group
  * @param int $group
  * @return array|boolean
  * @author QuangTM
  */
 public function getListLeagueByGroup($group)
 {
     // Get result
     $result = array();
     try {
         // Get DB Obj
         $dbObj = Thethao_Global::getDB('sport', 'slave');
         // Prepare SQL
         $stmt = $dbObj->prepare('CALL sp_fe_sport_getLeagueByGroup(:p_group);');
         // Bind param
         $stmt->bindParam('p_group', $group, PDO::PARAM_INT);
         // Execute
         $stmt->execute();
         while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
             $result[$row['league_id']] = $row['name'];
         }
         // Close
         $stmt->closeCursor();
         // Release variables
         unset($stmt);
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex, 1);
     }
     return $result;
 }
Пример #12
0
 /**
  * MatchBetrate: Get full data from DB
  * @param int $seasonID, $leagueID
  * @return array
  * @author Dungdv2
  */
 public function getMatchBetrateByIDs(array $arrMatchIDs)
 {
     // Set result
     $result = array();
     try {
         // Convert to string
         $strMatchIDs = implode(',', $arrMatchIDs);
         // Get DB Obj
         $dbObj = Thethao_Global::getDB('sport', 'slave');
         // Prepare SQL
         $stmt = $dbObj->prepare('CALL sp_sport_getMatchBetrate(:p_matchid);');
         // Bind param
         $stmt->bindParam('p_matchid', $strMatchIDs, PDO::PARAM_STR);
         // Execute
         $stmt->execute();
         while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
             $result[$row['match_id']] = $row;
         }
         // Close
         $stmt->closeCursor();
         // Release variables
         unset($stmt);
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex, 1);
     }
     return $result;
 }