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


PHP DBAccess::FetchAll方法代码示例

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


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

示例1: json_index

function json_index()
{
    $sql = new DBAccess();
    $player = get_player_info();
    $events = array();
    $messages = array();
    $user_id = $player['player_id'];
    if ($user_id) {
        $events = $sql->FetchAll("select event_id, message as event, date, send_to, send_from, unread, uname as sender from events join players on player_id = send_from where send_to = '" . sql($user_id) . "' order by date desc limit 1");
        //$chats = $sql->FetchAll("select * from chat order by time desc");
        $messages = $sql->FetchAll("select message_id, message, date, send_to, send_from, unread, uname as sender from messages join players on player_id = send_from where send_to = '" . sql($user_id) . "' and send_from != '" . sql($user_id) . "' order by date desc limit 1");
    }
    return '{"player":' . json_encode($player) . ',"message":' . json_encode(reset($messages)) . ',"event":' . json_encode(reset($events)) . '}';
}
开发者ID:ninjajerry,项目名称:ninjawars,代码行数:14,代码来源:api.php

示例2: clan_size

/**
 * This determines how the clans get ranked and tagged, and how to only show non-empty clans.
**/
function clan_size()
{
    $res = array();
    $db = new DBAccess();
    $sel = "select sum(level-3-round(days/5)) as sum, clan_long_name from players where confirmed = 1 group by clan_long_name order by sum desc";
    $counts = $db->FetchAll($sel);
    $largest = reset($counts);
    $max = $largest['sum'];
    foreach ($counts as $clan_info) {
        // make percentage of highest, multiply by 10 and round to give a 1-10 size
        $res[$clan_info['clan_long_name']] = floor(($clan_info['sum'] - 1 < 1 ? 0 : $clan_info['sum'] - 1) / $max * 10) + 1;
    }
    return $res;
}
开发者ID:ninjajerry,项目名称:ninjawars,代码行数:17,代码来源:lib_tags.php

示例3: player_size

/**
 * This determines how the clans get ranked and tagged, and how to only show non-empty clans.
**/
function player_size()
{
    $res = array();
    $db = new DBAccess();
    $sel = "select (level-3-round(days/5)) as sum, player_id, uname from players where confirmed = 1 and health>0 order by sum desc";
    $counts = $db->FetchAll($sel);
    $largest = reset($counts);
    $max = $largest['sum'];
    foreach ($counts as $player_info) {
        // make percentage of highest, multiply by 10 and round to give a 1-10 size
        $res[$player_info['uname']] = array('player_id' => $player_info['player_id'], 'size' => floor(($player_info['sum'] - 1 < 1 ? 0 : $player_info['sum'] - 1) / $max * 10) + 1);
    }
    return $res;
}
开发者ID:ninjajerry,项目名称:ninjawars,代码行数:17,代码来源:lib_player_list.php

示例4: render_clan_join

function render_clan_join($process = null, $username, $clan_name)
{
    $sql = new DBAccess();
    if ($process == 1) {
        $confirm = $sql->QueryItem("SELECT confirm FROM players WHERE uname = '{$username}'");
        $url = message_url("clan_confirm.php?clan_joiner=" . rawurlencode($username) . "&confirm={$confirm}&clan_name=" . rawurlencode($clan_name), 'Confirm Request');
        $join_request_message = "CLAN JOIN REQUEST: {$username} has sent you a clan request.\n            If you wish to allow this ninja into your clan click the following link:\n            {$url}";
        send_message(get_user_id($username), get_user_id($clan_name), $join_request_message);
        echo "<div>***Your request to join this clan has been sent to {$clan_name}***</div>\n";
    } else {
        //Clan Join list of available Clans
        $clan_leaders = $sql->FetchAll("SELECT uname,level,clan,clan_long_name FROM players\n            WHERE lower(uname) = lower(clan) AND clan_long_name != '' AND confirmed = 1");
        echo "<p>Clans Available to Join</p>\n        <p>To send a clan request click on that clan leader's name.</p>\n        <ul>";
        foreach ($clan_leaders as $leader) {
            echo "<li><a href=\"clan.php?command=join&clan_name={$leader['clan']}&process=1\">\n                    Join {$leader['clan_long_name']}</a>.\n                    Its leader is <a href=\"player.php?player=" . rawurlencode($leader['uname']) . "\">\n                    {$leader['uname']}</a>, level {$leader['level']}.\n                    <a href=\"clan.php?command=view&clan_name={$leader['clan']}\">View This Clan</a>\n                </li>\n";
        }
        echo "</ul>";
    }
}
开发者ID:ninjajerry,项目名称:ninjawars,代码行数:19,代码来源:lib_clan.php

示例5: get_recent_attackers

function get_recent_attackers()
{
    $recent_attackers = array();
    $user_id = get_user_id();
    $sql = new DBAccess();
    $q = 'select distinct send_from, uname, level, health from events join players on send_from = player_id where send_to = \'' . sql($user_id) . '\' limit 20';
    $sql->Query($q);
    $recent_attackers = $sql->FetchAll();
    return $recent_attackers;
}
开发者ID:ninjajerry,项目名称:ninjawars,代码行数:10,代码来源:enemies.php


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