public function getMemberGames($id) { $MemberGames = MemberGames::model()->findByAttributes(array('mid' => $id)); if ($MemberGames) { for ($i = 1; $i < 7; $i++) { $value = "gid" . $i; if ($MemberGames->{$value}) { $MemberGamesArr[] = $MemberGames->{$value}; } } return $MemberGamesArr; } }
public function memberGames($mid, $gid, $serverIdValue) { $modelMemberGames = new MemberGames(); $MemberGames = $modelMemberGames->findByAttributes(array('mid' => $mid)); if ($MemberGames) { $MemberGamesArr = array(); for ($i = 1; $i <= 6; $i++) { $gidNum = 'gid' . $i; if ($MemberGames->{$gidNum} !== null) { $MemberGamesArr[$i] = unserialize($MemberGames->{$gidNum}); } else { continue; } } foreach ($MemberGamesArr as $vo) { if ($vo['gid'] == $gid && $vo['serveridvalue'] == $serverIdValue) { return $vo; } } if ($MemberGames->gnum >= 6) { $gidTest = serialize(array('gid' => $gid, 'serveridvalue' => $serverIdValue)); $modelMemberGames->updateAll(array('gnum' => '1', 'gid1' => $gidTest), "mid={$mid}"); //echo 6; return true; } else { $gnum = $MemberGames->gnum + 1; $prefixgId = 'gid' . $gnum; $gidTest = serialize(array('gid' => $gid, 'serveridvalue' => $serverIdValue)); $modelMemberGames->updateAll(array('gnum' => $gnum, $prefixgId => $gidTest), "mid={$mid}"); //echo $gnum; return true; } } else { $modelMemberGames->mid = $mid; $modelMemberGames->gnum = 1; $modelMemberGames->gid1 = serialize(array('gid' => $gid, 'serveridvalue' => $serverIdValue)); $modelMemberGames->save(false); } }
<p>您尚未进行防沉迷认证!</p> <a href="<?php echo Yii::app()->request->baseUrl; ?> /member/idcard" style="color:red;text-decoration:none;">立即认证>>></a> <?php } ?> <form> </form> </div> <div class="mr_game"> <h1>玩过的游戏</h1> <ul> <?php $memberGamesarr = MemberGames::model()->getMemberGames(Yii::app()->user->id); if ($memberGamesarr) { foreach ($memberGamesarr as $value) { $value = unserialize($value); $memberGamesname = Games::model()->getGamesName($value['gid']); if ($memberGamesname) { $memberGamesimages = Games::model()->getGamesImage($value['gid']); $GetGamesServerId = Games::model()->getGamesServerValue($value['gid'], $value['serveridvalue']); echo "<li><a target='_blanck' href='" . Yii::app()->request->baseUrl . "/gameslogin/index?gametype=" . $memberGamesname[1] . "&serverid=" . $GetGamesServerId . "'><img alt='" . $memberGamesname[0] . "-" . $GetGamesServerId . "区' title='" . $memberGamesname[0] . "-" . $GetGamesServerId . "区' height='64px' width='64px' src='http://918s-game.stor.sinaapp.com/" . $memberGamesimages[1] . "'/><p>" . $memberGamesname[0] . "</p></a></li>"; } } } else { echo '暂时没有玩过任何游戏!'; } ?>
/** * Lists all models. */ public function actionIndex() { $memberMessage = Member::model()->getMemberMessage(Yii::app()->user->id); /*$memberHeadImg=$memberMessage->headimg; if(empty($memberHeadImg)){ $memberHeadImg="uploads/headimg/headimg-default.jpg"; }*/ $memberGames = MemberGames::model()->findByAttributes(array('mid' => Yii::app()->user->id)); $memberEmail = Member::model()->findByAttributes(array('id' => Yii::app()->user->id)); /*if($memberGames){ for($i=1;$i<7;$i++){ if($memberGames->{gid.$i}){ $memberGamesarr[]= unserialize($memberGames->{gid.$i}); } } }*/ $model = $this->loadModel(Yii::app()->user->id); if (isset($_POST['Member'])) { $model->attributes = $_POST['Member']; if ($model->save()) { $this->redirect('index'); } } $this->render('view', array('model' => $this->loadModel(Yii::app()->user->id))); }