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


PHP Vars::set方法代碼示例

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


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

示例1: exit

<?php

if (!defined('BASEPATH')) {
    exit('Nu poti accesa acest fisier direct.');
}
$expire = $CFG->get('rank_regenerate');
$expire = 0;
if (Cache::is_cached('top_10_players', $expire)) {
    Vars::set('players_rank', Cache::get('top_10_players'));
} else {
    $players = array();
    $sql = "SELECT player.id, player.name, player.level, player_index.empire \n                FROM " . PLAYER_DATABASE . ".player \n                LEFT JOIN " . PLAYER_DATABASE . ".player_index ON player_index.id=player.account_id \n                LEFT JOIN " . PLAYER_DATABASE . ".guild_member ON guild_member.pid=player.id \n                INNER JOIN " . ACCOUNT_DATABASE . ".account \n                ON account.id=player.account_id\n                WHERE player.name NOT LIKE '[%]%' AND account.status!='BLOCK'\n            ORDER BY player.level DESC, player.exp DESC LIMIT 10";
    $query = $DB->query($sql);
    while ($row = $DB->fetch($query)) {
        $players[] = $row;
    }
    Cache::set('top_10_players', $players);
    Vars::set('players_rank', $players);
}
if (Cache::is_cached('top_10_guilds', $expire)) {
    Vars::set('guilds_rank', Cache::get('top_10_guilds'));
} else {
    $guilds = array();
    $sql = "SELECT \n        guild.name, guild.level, guild.win, guild.ladder_point, player_index.empire\n        FROM " . PLAYER_DATABASE . ".guild  \n        LEFT JOIN " . PLAYER_DATABASE . ".player ON guild.master = player.id \n        LEFT JOIN " . PLAYER_DATABASE . ".player_index ON player_index.id = player.account_id \n        WHERE player.name NOT LIKE '[%]%' \n        ORDER BY guild.ladder_point DESC LIMIT 10";
    $query = $DB->query($sql);
    while ($row = $DB->fetch($query)) {
        $guilds[] = $row;
    }
    Cache::set('top_10_guilds', $guilds);
    Vars::set('guilds_rank', $guilds);
}
開發者ID:ionutmilica,項目名稱:my-archive,代碼行數:31,代碼來源:getRank.php

示例2: define

/**
 * @todo: Replace this code with a proper router
**/
define('DS', DIRECTORY_SEPARATOR);
define('BASEPATH', realpath(dirname(__FILE__)) . DS);
define('APPPATH', BASEPATH . 'application' . DS);
require BASEPATH . 'system' . DS . 'core.php';
define('LOGGED_IN', is_logged_in());
$smarty->assign('logged_in', LOGGED_IN);
if (isset($_SESSION['user_data']['id'])) {
    $smarty->assign('user_id', $_SESSION['user_data']['id']);
} else {
    $smarty->assign('user_id', 0);
}
/* ----- Use a router insted ----- */
$query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
$req_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
$request = str_replace($CFG->get('relative_path'), '', $req_uri);
$request = str_replace('?' . $query, '', $request);
$url_parts = explode('/', trim($request, '/'));
$url_parts[0] = isset($url_parts[0]) && $url_parts[0] != '' ? $url_parts[0] : '';
$url_parts = str_replace('..', '', $url_parts);
/* ---------- */
$file = plugin($url_parts);
Vars::set('args', $url_parts);
Vars::set('plain_args', implode('/', $url_parts));
require $file;
require BASEPATH . 'getRank.php';
$smarty->assign('players_rank', Vars::get('players_rank'));
$smarty->assign('guilds_rank', Vars::get('guilds_rank'));
$smarty->display('main.tpl');
開發者ID:ionutmilica,項目名稱:my-archive,代碼行數:31,代碼來源:index.php


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