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


PHP DBAccess::Query方法代码示例

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


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

示例1: render_chat_messages

/**
 * Render the div full of chat messages.
 * @param $chatlength Essentially the limit on the number of messages.
**/
function render_chat_messages($chatlength, $show_elipsis = null)
{
    // Eventually there might be a reason to abstract out get_chats();
    $sql = new DBAccess();
    $sql->Query("SELECT sender_id, uname, message, age(now(), date) as ago FROM chat join players on chat.sender_id = player_id ORDER BY chat_id DESC LIMIT {$chatlength}");
    // Pull messages
    $chats = $sql->fetchAll();
    $message_rows = '';
    $messageCount = $sql->QueryItem("select count(*) from chat");
    if (!isset($show_elipsis) && $messageCount > $chatlength) {
        $show_elipsis = true;
    }
    $res = "<div class='chatMessages'>";
    $previous_date = null;
    $skip_interval = 3;
    // minutes
    foreach ($chats as $messageData) {
        $l_ago = time_ago($messageData['ago'], $previous_date);
        $message_rows .= "<li>&lt;<a href='player.php?player_id={$messageData['sender_id']}'\n\t\t     target='main'>{$messageData['uname']}</a>&gt; " . out($messageData['message']) . " <span class='chat-time'>{$l_ago}</span></li>";
        $previous_date = $messageData['ago'];
        // Store just prior date.
    }
    $res .= $message_rows;
    if ($show_elipsis) {
        // to indicate there are more chats available
        $res .= ".<br>.<br>.<br>";
    }
    $res .= "</div>";
    return $res;
}
开发者ID:ninjajerry,项目名称:ninjawars,代码行数:34,代码来源:lib_chat.php

示例2: update_last_attack_time

/**
 * Attack function library.
 * @package combat
 * @subpackage lib_attack
**/
function update_last_attack_time($player_id, $sql = null)
{
    if (!$sql) {
        $sql = new DBAccess();
    }
    $update_last_attacked = "update players set last_started_attack=now() where player_id='" . intval($player_id) . "'";
    $sql->Query($update_last_attacked);
    // updates the timestamp of the last_attacked column to slow excessive attacks.
}
开发者ID:ninjajerry,项目名称:ninjawars,代码行数:14,代码来源:lib_attack.php

示例3: 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

示例4: array

// *** Max time a person is kept online without being active.
$turn_regen_threshold = 100;
$out_display = array();
// ******************* END OF CONSTANTS ***********************
$sql->Update("UPDATE time SET amount = amount+1 WHERE time_label='hours'");
// Update the hours ticker.
$sql->Update("UPDATE time SET amount = 0 WHERE time_label='hours' AND amount>=24");
// Rollover the time to hour zero.
$sql->Update("UPDATE players SET turns = 0 WHERE turns < 0");
$sql->Update("UPDATE players SET bounty = 0 WHERE bounty < 0");
$sql->Update("UPDATE players SET turns = turns+1 WHERE class ='Blue' and turns < " . $turn_regen_threshold);
// Blue turn code
$sql->Update("UPDATE players SET turns = turns+2 where turns < " . $turn_regen_threshold);
// add 2 turns on the hour, up to 100.
// Database connection information here
$sql->Query("DELETE FROM ppl_online WHERE activity < (now() - interval '" . $maxtime . "')");
//Skip error logging this for now. $out_display['Inactive Browsers Deactivated'] = $sql->a_rows;
// *** HEAL ***
$sql->Update("UPDATE players SET health=numeric_smaller(health+8, {$maximum_heal}) " . "WHERE health BETWEEN 1 AND {$maximum_heal} AND NOT " . "cast(status&" . POISON . " AS boolean)");
// ****************************** RESURRECTION CHECK, DEPENDENT UPON RESURRECTION_TIME ****************************
/* OLD System
$minimum = 2;
$by_percent = true;
$maximum = 4;

$resurrect_info = revive_appropriate_players($minimum, $maximum, $by_percent, $just_testing=false);
assert($resurrect_info['revived']<$resurrect_info['target_number']);
*/
// New system, potentially move to the halfhour, and then half the major_revive_percent?
$params = array('full_max' => 50, 'minor_revive_to' => 150, 'major_revive_percent' => 5);
$resurrected = revive_players($params);
开发者ID:ninjajerry,项目名称:ninjawars,代码行数:31,代码来源:deity_hourly.php

示例5: dirname

<?php

require_once dirname(__FILE__) . '/../lib/base.inc.php';
// Currently this forces crons locally to be called from the cron folder.
require_once LIB_ROOT . "specific/lib_deity.php";
// Deity-specific functions
$sql = new DBAccess();
$sql->Query("truncate player_rank");
$sql->Query("SELECT setval('player_rank_rank_id_seq1', 1, false);");
$sql->Query("insert into player_rank (_player_id, score) select player_id, ((level*900) + (CASE WHEN gold < 1 THEN 0 ELSE floor(gold/200) END) + (kills*3) - (days*5)) AS score from players WHERE confirmed = 1 ORDER BY score DESC");
#   Running from a cron script, we don't want any output unless we have an error
$out_display['Ranked Players'] = $sql->a_rows;
// ***********
// Log output:
$logMessage = "DEITY_FIVEMINUTE STARTING: " . date(DATE_RFC1036) . "\n";
foreach ($out_display as $loopKey => $loopRowResult) {
    $logMessage .= "DEITY_FIVEMINUTE: Result type: {$loopKey} yeilded result number: {$loopRowResult} \n";
}
$logMessage .= "DEITY_FIVEMINUTE ENDING: " . date(DATE_RFC1036) . "\n";
$log = fopen(LOGS . 'deity.log', 'a');
fwrite($log, $logMessage);
fclose($log);
开发者ID:ninjajerry,项目名称:ninjawars,代码行数:22,代码来源:deity_fiveminute.php


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