當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Player::model方法代碼示例

本文整理匯總了PHP中Player::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Player::model方法的具體用法?PHP Player::model怎麽用?PHP Player::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Player的用法示例。


在下文中一共展示了Player::model方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validateToken

 public function validateToken($token, $player_id)
 {
     $check = Player::model()->findByAttributes(array('id' => $player_id, 'token' => $token));
     if ($check) {
         return true;
     }
     return false;
 }
開發者ID:huynt57,項目名稱:quizder,代碼行數:8,代碼來源:Util.php

示例2: run

 public function run()
 {
     if (Yii::app()->user->isGuest) {
         $this->render('_menuGuest');
     } else {
         $player = Player::model()->findByAttributes(array('email' => Yii::app()->user->id));
         $this->render('_menuPlayer', array('player' => $player));
     }
 }
開發者ID:ressh,項目名稱:space.serv,代碼行數:9,代碼來源:MenuPlayer.php

示例3: getTournamentDetail

 public static function getTournamentDetail($id)
 {
     if (!$id) {
         return false;
     }
     $return = Yii::app()->cache->get(self::CACHE_PREFIX . $id);
     if (!$return) {
         $tournament = Tournament::model()->findByPk($id);
         if (!$tournament) {
             return false;
         }
         $return['t'] = $tournament;
         if ($tournament->player_joined > 0) {
             if (in_array($tournament->status, array('playing', 'ended', 'signing'))) {
                 //查詢參賽者數據
                 $players_id = Tournament_join::model()->getDbConnection()->createCommand('select * from tournament_join where tid=' . $id)->queryAll();
                 $tmp = array();
                 $return['players_join'] = array();
                 foreach ($players_id as $v) {
                     $tmp[] = $v['uid'];
                     $return['players_join'][$v['uid']] = $v;
                 }
                 $players = Player::model()->findAll('id in(' . implode(',', $tmp) . ')');
                 //整理player的id對應
                 $players_arr = array();
                 foreach ($players_id as $v) {
                     $players_arr[$v['uid']] = $v['t_sn'];
                 }
                 $return['players'] = array();
                 foreach ($players as $p) {
                     $return['players'][$players_arr[$p->id]] = $p;
                 }
                 ksort($return['players']);
             }
             if (in_array($tournament->status, array('playing', 'ended'))) {
                 //查詢對局數據
                 $games = Games::model()->findAll('tid=' . $id);
                 //整理對陣表
                 $games_table = array();
                 foreach ($games as $g) {
                     $x = $g->black_id;
                     $y = $g->white_id;
                     //如果是單循環,隻填充右上的一半對陣表
                     if ($tournament->t_kind == 'single') {
                         if ($players_arr[$x] < $players_arr[$y]) {
                             list($x, $y) = array($y, $x);
                         }
                     }
                     $games_table[$players_arr[$y]][$players_arr[$x]] = $g;
                 }
                 $return['games_table'] = $games_table;
             }
         }
         Yii::app()->cache->set(self::CACHE_PREFIX . $id, $return, 600);
     }
     return $return;
 }
開發者ID:xsir317,項目名稱:5zer,代碼行數:57,代碼來源:TournamentTool.php

示例4: _userinfo

 public function _userinfo()
 {
     if (!$this->userinfo) {
         if (!Yii::app()->user->isGuest) {
             $user_id = Yii::app()->user->getState('id');
             if ($user_id) {
                 $this->userinfo = Player::model()->findByPk($user_id);
             }
         }
     }
     return $this->userinfo;
 }
開發者ID:xsir317,項目名稱:5zer,代碼行數:12,代碼來源:MyController.php

示例5: authenticate

 public function authenticate()
 {
     $user = Player::model()->find('email=:user and password=:pass', array(':user' => $this->username, ':pass' => self::hashpwd($this->password)));
     if ($user) {
         $user->last_login_ip = MyController::getUserHostAddress();
         $user->last_login_time = date('Y-m-d H:i:s');
         $user->login_times++;
         $user->save();
         Yii::app()->user->setState('id', $user->id);
         return true;
     } else {
         return false;
     }
 }
開發者ID:xsir317,項目名稱:5zer,代碼行數:14,代碼來源:MyUserIdentity.php

示例6: actionReg

 public function actionReg()
 {
     $email = trim(Yii::app()->request->getParam('email'));
     $nick = trim(Yii::app()->request->getParam('nickname'));
     $password = trim(Yii::app()->request->getParam('passwd'));
     $password2 = trim(Yii::app()->request->getParam('passwd2'));
     $refer = trim(Yii::app()->request->getParam('refer', '/'));
     if (!preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i', $email)) {
         $this->json_return(false, '請輸入一個格式正確的Email地址');
     }
     if (!$password || $password != $password2) {
         $this->json_return(false, '2次輸入的密碼不一致');
     }
     if (!$nick) {
         $this->json_return(false, '請填寫昵稱');
     }
     if (mb_strlen($nick, 'UTF-8') > 9) {
         $this->json_return(false, '昵稱長度請限製在9個字之內');
     }
     if (Player::model()->find('email=:email', array(':email' => $email))) {
         $this->json_return(false, '這個Email已經被注冊了,您是否已經注冊過了呢?');
     }
     if (Player::model()->find('nickname=:nick', array(':nick' => $nick))) {
         $this->json_return(false, '這個昵稱已經被注冊了,換一個吧');
     }
     $player = new Player();
     $player->email = $email;
     $player->nickname = $nick;
     $player->password = MyUserIdentity::hashpwd($password);
     $player->login_times = 0;
     $player->b_win = 0;
     $player->b_lose = 0;
     $player->w_win = 0;
     $player->w_lose = 0;
     $player->draw = 0;
     $player->reg_time = date('Y-m-d H:i:s');
     $player->reg_ip = MyController::getUserHostAddress();
     $player->last_login_time = date('Y-m-d H:i:s');
     $player->last_login_ip = MyController::getUserHostAddress();
     $player->score = Yii::app()->params['init_score'];
     if ($player->save()) {
         $identity = new MyUserIdentity($email, $password);
         if ($identity->authenticate()) {
             Yii::app()->user->login($identity, 3600);
             $this->json_return(true, '恭喜您注冊成功!', $refer);
         }
     }
     $this->json_return(false, '注冊失敗啦,請與管理員聯係。');
 }
開發者ID:xsir317,項目名稱:5zer,代碼行數:49,代碼來源:MemberController.php

示例7: authenticate

 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = Player::model()->findByAttributes(array('email' => $this->username));
     if ($user === null) {
         // No user was found!
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (md5($this->password) !== $user->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             // User/pass match
             $this->_id = $user->id;
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
開發者ID:ressh,項目名稱:space.serv,代碼行數:25,代碼來源:UserIdentity.php

示例8: checkToChanging

 public function checkToChanging()
 {
     $player = Player::model()->findByAttributes(array('email' => Yii::app()->user->id));
     if ($this->validate()) {
         if ($player->getSummExit() >= $this->summ) {
             if ($player->setSummExitPlus(-$this->summ)) {
                 $player->setSummBuyPlus($this->summ * 1.1);
                 $this->redirect($this->createUrl('player/Myship'));
             } else {
                 $this->addError('summ', 'Ошибка. Обмен не произошел!');
             }
         } else {
             $this->addError('summ', 'Обмен не произошел, возможно не хватает средств.');
             return false;
         }
     } else {
         return false;
     }
 }
開發者ID:ressh,項目名稱:space.serv,代碼行數:19,代碼來源:FormChangeOutMoneyToBuy.php

示例9: actionManageMatchGameByPlayer

 /**
  * Manages Player Results
  * @param Integer $id
  * @param Integer $playerId
  */
 public function actionManageMatchGameByPlayer($id, $playerId)
 {
     $MATCH_TYPE = 2;
     $ACTIVE = 1;
     $model = $this->loadModel($id);
     $playerModel = Player::model()->findByPK($playerId);
     if ($playerModel === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     if (isset($_POST['PlayerResult'])) {
         $players = $_POST['PlayerResult'];
         foreach ($players as $playerResultPost) {
             $catResult = isset($playerResultPost['RESULT_ID']) ? $playerResultPost['RESULT_ID'] : -1;
             $matchId = isset($playerResultPost['MATCH_ID']) ? $playerResultPost['MATCH_ID'] : -1;
             $playerResult = PlayerResult::model()->findByPK(array('RESULT_ID' => $catResult, 'PLAYER_ID' => $playerId, 'MATCH_ID' => $matchId));
             if ($playerResult != null) {
                 $playerResult->attributes = $playerResultPost;
                 $playerResult->save();
             } else {
                 throw new CHttpException(404, 'The requested page does not exist.');
             }
         }
         $this->redirect(array('manage', 'id' => $matchId));
     }
     $catResult = new CatResult();
     $catResult->TYPE_RESULT = $MATCH_TYPE;
     $catResult->ACTIVE = $ACTIVE;
     $catResults = array();
     $catResults = $catResult->search()->getData();
     $playerResults = array();
     foreach ($catResults as $_catResult) {
         $playerResult = PlayerResult::model()->findByPK(array('RESULT_ID' => $_catResult->ID, 'PLAYER_ID' => $playerId, 'MATCH_ID' => $id));
         if ($playerResult === null) {
             $playerResult = new PlayerResult();
             $playerResult->MATCH_ID = $id;
             $playerResult->PLAYER_ID = $playerId;
             $playerResult->RESULT_ID = $_catResult->ID;
             $playerResult->save();
         }
         $playerResults[] = $playerResult;
     }
     $this->renderPartial('_playerResultForm', array('model' => $model, 'playerModel' => $playerModel, 'playerResults' => $playerResults));
 }
開發者ID:elgodmaster,項目名稱:soccer2,代碼行數:48,代碼來源:MatchGameController.php

示例10: actionRun

 /**
  * Displays the contact page
  */
 public function actionRun()
 {
     require __DIR__ . '/../../../vendor/autoload.php';
     $evm = new EventManager();
     $data = array();
     $collect = function ($info) use(&$data) {
         $data[] = $info;
     };
     $evm->on('game.run', $collect);
     $evm->on('game.addplayer', $collect);
     $evm->on('game.start', $collect);
     $evm->on('game.turn', $collect);
     $evm->on('game.end', $collect);
     $evm->on('player.start', $collect);
     $evm->on('player.attack', $collect);
     $evm->on('player.defense', $collect);
     $evm->on('player.damage', $collect);
     $game = new Game($evm);
     foreach (Player::model()->findAll() as $player) {
         $game->addPlayer(new EPlayer($player->name, (int) $player->life, (int) $player->strong, (int) $player->speed, new EResource($player->resource->name, (int) $player->resource->attack, (int) $player->resource->defense, new Dice((int) $player->resource->dice)), $game));
     }
     $game->run(new Dice(20));
     $this->render('run', array('data' => $data));
 }
開發者ID:rafaelang,項目名稱:rpg,代碼行數:27,代碼來源:SiteController.php

示例11: actionScorelog

 public function actionScorelog()
 {
     $id = intval(Yii::app()->request->getParam('id'));
     $player = Player::model()->findByPk($id);
     if (!$id || !$player) {
         throw new CHttpException(404);
     }
     $history = Score_log::model()->findAll("player_id={$id} order by id desc");
     //TODO 分頁
     $this->pageTitle = '用戶等級分曆史記錄:' . $player->nickname . '  ' . Yii::app()->params['title'];
     $this->render('scorelog', array('player' => $player, 'history' => $history));
 }
開發者ID:xsir317,項目名稱:5zer,代碼行數:12,代碼來源:SiteController.php

示例12: getLeaderBoardFriends

 public function getLeaderBoardFriends($user_id, $friends, $quiz)
 {
     $sql = "SELECT derived.player_id, sum(derived.best_score) AS player_points \nFROM (\n    SELECT tbl_game.quiz_id, tbl_game.player_id, max(tbl_game.player_points) AS best_score \n    FROM `tbl_game` \n    WHERE tbl_game.player_id IN {$friends} \n    AND tbl_game.quiz_id = {$quiz}\n    GROUP BY tbl_game.player_id\n) as derived \nGROUP BY derived.player_id\nORDER BY player_points DESC";
     $players = Game::model()->findAllBySql($sql);
     $arr = array();
     //        $player_id_arr = array();
     //        $player_points_arr = array();
     foreach ($players as $item) {
         $arr[$item->player_id] = $item->player_points;
         // $player_points_arr
     }
     $player_point = null;
     $position = array_search($user_id, array_keys($arr));
     if ($position === FALSE) {
         $position = null;
     }
     //echo $position; die;
     if (isset($position)) {
         $player_point = $arr[$user_id];
     }
     $returnArr = array();
     //  var_dump($player_point); die;
     foreach ($players as $player) {
         $itemArr = array();
         $itemArr['player_info'] = Player::model()->findByPk($player->player_id);
         $itemArr['player_points'] = $player->player_points;
         $returnArr[] = $itemArr;
     }
     return array('items' => $returnArr, 'current_position' => $position, 'current_points' => $player_point);
 }
開發者ID:huynt57,項目名稱:quizder,代碼行數:30,代碼來源:Player.php

示例13: actionOutsHighDartModal

 public function actionOutsHighDartModal()
 {
     if (Yii::app()->request->isPostRequest) {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
     $message = 'success';
     if (isset($_GET['data'])) {
         $data = $_GET['data'];
         $tournament_id = $data['tournament_id'];
         $player_id = $data['player_id'];
         $player = Player::model()->findByPk($player_id);
         $outs = $player->getOuts($tournament_id);
         $high_dart = $player->getHighDart($tournament_id);
     }
     echo CJSON::encode(array('status' => $message, 'outs' => $outs, 'high_dart' => $high_dart));
 }
開發者ID:cfletcher1856,項目名稱:austinblinddraw,代碼行數:16,代碼來源:TournamentController.php

示例14: array



<div class="view">

<?php 
//get player complement Data
$player = Player::model()->findByPk($data->PLAYER_ID);
$imgDel = CHtml::image(Yii::app()->request->baseUrl . '/images/del.png', '');
$imgEdit = CHtml::image(Yii::app()->request->baseUrl . '/images/update.png', '');
?>

<table>
<tr>
<td width="70%">
	<b><?php 
echo CHtml::encode($data->getAttributeLabel('ID'));
?>
:</b>
	<?php 
echo CHtml::link(CHtml::encode($data->PLAYER_ID), array('view', 'id' => $data->PLAYER_ID));
?>

	&nbsp;
	<b><?php 
echo CHtml::encode($player->getAttributeLabel('NAME'));
?>
:</b>
	<?php 
echo CHtml::encode($player->NAME);
?>
	<br />
開發者ID:elgodmaster,項目名稱:soccer2,代碼行數:29,代碼來源:_viewPlayers.php

示例15: loadModel

 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Player::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
開發者ID:cfletcher1856,項目名稱:austinblinddraw,代碼行數:13,代碼來源:PlayerController.php


注:本文中的Player::model方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。