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


PHP Game::insert方法代码示例

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


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

示例1: createAction

 public function createAction()
 {
     $Game = new Game();
     $data = array('user_id' => $this->sessionUserId, 'title' => $this->_request->title, 'description' => $this->_request->description, 'price' => $this->_request->price, 'genre_id' => implode(',', $this->_request->genre_id), 'no_times_played' => $this->_request->no_times_played, 'purchase_date' => $this->_request->purchase_date);
     $Game->insert($data);
     $this->_redirect('main/index');
 }
开发者ID:biscuiteater,项目名称:gamebox,代码行数:7,代码来源:GamesController.php

示例2: create

 public static function create($m_id, $g_name, $access_key)
 {
     F::i(_DBMS_SYS)->exec('INSERT INTO !prefix_games (g_id, m_id, g_name, g_access_key) VALUES (NULL, ?, ?, ?)', array($m_id, $g_name, $access_key));
     $game = new Game(F::i(_DBMS_SYS)->getInsertId());
     $game->insert($m_id);
     return $game;
 }
开发者ID:Korko,项目名称:RiskOnline,代码行数:7,代码来源:Game.php

示例3: getView

    public function getView($params, $synchrone)
    {
        $search_form = new Form($this->search_fields, $params);
        $access_form = new Form($this->access_fields, $params);
        $title = '';
        $insert = TRUE;
        try {
            if (!isset($params['game'])) {
                throw new Exception('No Game given');
            }
            $game = new Game($params['game']);
            if ($game->isIn(F::i('Session')->getMid())) {
                throw new Exception('Already In');
            }
        } catch (Exception $e) {
            $insert = FALSE;
        }
        if ($insert) {
            if ($game->g_access_key == 'NULL' || $access_form->isSubmitting() && Tools::isEmpty($access_form->getErrors()) && $game->g_access_key == Tools::saltHash($params['access_key'])) {
                $game->insert(F::i('Session')->getMid());
                Tools::redirect('?action=wait_game&game=' . $game->g_id);
            } else {
                // CHECK
                if ($access_form->isSubmitting()) {
                    // Error
                    die('bad access key');
                } else {
                    $view = View::setFile('formular', View::HTML_FILE);
                    $errors = $access_form->getErrors();
                    // Errors in the filling
                    if (!empty($errors)) {
                        $view->setSwitch('form_errors', TRUE);
                        foreach ($errors as $field => $error) {
                            $view->setGroupValues('form_errors', array('error' => F::i('Lang')->getKey('error_' . $field . '_' . $error)));
                        }
                    }
                    $view->setValue('form', $access_form->getHTML(F::i('Lang')->getKey('access_key'), '#', 'POST', 'tabbed_form'));
                }
            }
        } else {
            $sql = 'SELECT g.g_id, g_name, TIMESTAMPDIFF(HOUR, g_start, NOW()) AS lifetime, COUNT(*) AS g_total_players, m_login AS g_owner 
					FROM !prefix_members m, !prefix_games AS g, !prefix_players AS p 
					WHERE g.m_id = m.m_id 
						AND p.g_id = g.g_id 
						AND g.g_id NOT IN (
							SELECT g_id FROM !prefix_players WHERE m_id = ?
						)';
            $array = array(F::i('Session')->getMid());
            // If search is defined, add condition
            if (isset($params['search'])) {
                $sql .= ' AND g_name LIKE ?';
                $array[] = '%' . $params['search'] . '%';
            }
            $sql .= ' GROUP BY g.g_id ORDER BY g_start DESC';
            // Get all the games
            $result = F::i(_DBMS_SYS)->query($sql, $array);
            $view = View::setFile('list_games', View::HTML_FILE);
            $view->setValue('form', $search_form->getHTML('', '#', 'POST', 'inline'));
            if ($result->getNumRows() == 0) {
                $view->setSwitch('no_games', TRUE);
            }
            for ($i = 0; $i < $result->getNumRows(); $i++) {
                $obj = $result->getObject();
                $view->setGroupValues('games', array('link' => '?action=join_game&game=' . $obj->g_id, 'name' => stripslashes($obj->g_name), 'total_players' => $obj->g_total_players, 'owner' => $obj->g_owner, 'lifetime' => $obj->lifetime));
            }
            $title = F::i('Lang')->getKey('title_join_game');
        }
        return parent::setBody($view);
    }
开发者ID:Korko,项目名称:RiskOnline,代码行数:69,代码来源:join_game.php

示例4: array

    $apiKeys = json_decode($config["fantasyData"]);
    $opts = array('http' => array('method' => "GET", 'header' => "Content-Type: application/json\r\nOcp-Apim-Subscription-key: " . $apiKeys->NFL, 'content' => "{body}"));
    $context = stream_context_create($opts);
    // response from api
    $seasoning = ["2015", "2016"];
    foreach ($seasoning as $season) {
        $response = file_get_contents("https://api.fantasydata.net/nfl/v2/JSON/Schedules/{$season}", false, $context);
        $data = json_decode($response);
        foreach ($data as $game) {
            $badDate = str_replace("T", " ", $game->Date);
            if (empty($badDate) === false) {
                $teamChavez = Team::getTeamByTeamApiId($pdo, $game->AwayTeam);
                $teamPaul = Team::getTeamByTeamApiId($pdo, $game->HomeTeam);
                if ($teamChavez !== null && $teamPaul !== null) {
                    $gameToInsert = new Game(null, $teamChavez->getTeamId(), $teamPaul->getTeamId(), $badDate);
                    $gameToInsert->insert($pdo);
                } else {
                    echo "<p>* * * SIX OF THIRTEEN SKIPPED THIS GAME * * *</p>" . PHP_EOL;
                }
            }
        }
    }
} catch (Exception $exception) {
    echo "Something went wrong: " . $exception->getMessage() . PHP_EOL;
} catch (TypeError $typeError) {
    echo "Something went wrong: " . $typeError->getMessage() . PHP_EOL;
}
//downloader for players NFL
try {
    $seasoning = ["2015", "2016"];
    foreach ($seasoning as $season) {
开发者ID:chrispaul3625,项目名称:sprots,代码行数:31,代码来源:apiDataDownLoaderNfl.php

示例5: getGames

function getGames(string $league)
{
    try {
        // grab the db connection
        $pdo = connectToEncryptedMySQL("/etc/apache2/capstone-mysql/sprots.ini");
        $config = readConfig("/etc/apache2/capstone-mysql/sprots.ini");
        $apiKeys = json_decode($config["fantasyData"]);
        $opts = array('http' => array('method' => "GET", 'header' => "Content-Type: application/json\r\nOcp-Apim-Subscription-key: " . $apiKeys->{$league}, 'content' => "{body}"));
        $context = stream_context_create($opts);
        // response from api
        $seasoning = ["2015", "2016"];
        foreach ($seasoning as $season) {
            $response = file_get_contents("https://api.fantasydata.net/{$league}/v2/JSON/Games/{$season}", false, $context);
            $data = json_decode($response);
            foreach ($data as $game) {
                $badDate = str_replace("T", " ", $game->DateTime);
                if (empty($badDate) === false) {
                    $teamChavez = Team::getTeamByTeamApiId($pdo, $game->AwayTeamID);
                    $teamPaul = Team::getTeamByTeamApiId($pdo, $game->HomeTeamID);
                    if ($teamChavez !== null && $teamPaul !== null) {
                        $gameToInsert = new Game(null, $teamChavez->getTeamId(), $teamPaul->getTeamId(), $badDate);
                        $gameToInsert->insert($pdo);
                    } else {
                        echo "<p>* * * SIX OF THIRTEEN SKIPPED THIS GAME * * *</p>" . PHP_EOL;
                    }
                }
            }
        }
    } catch (Exception $exception) {
        echo "Something went wrong: " . $exception->getMessage() . PHP_EOL;
    } catch (TypeError $typeError) {
        echo "Something went wrong: " . $typeError->getMessage() . PHP_EOL;
    }
}
开发者ID:chrispaul3625,项目名称:sprots,代码行数:34,代码来源:genericDownloader.php

示例6: testGetValidGameByGameId

 /**
  * test inserting a valid Game and regrabbing it from mySQL
  **/
 public function testGetValidGameByGameId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("game");
     // create a new Game and insert to into mySQL
     $game = new Game(null, $this->game->getGameId(), $this->VALID_GAME);
     $game->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoGame = Game::getGameByGameId($this->getPDO(), $game->getGameId());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("game"));
     $this->assertEquals($pdoGame->getGameId(), $this->game->getGameId());
 }
开发者ID:chrispaul3625,项目名称:sprots,代码行数:15,代码来源:MasterTestIgnore.php


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