本文整理汇总了PHP中DBAccess::QueryAssoc方法的典型用法代码示例。如果您正苦于以下问题:PHP DBAccess::QueryAssoc方法的具体用法?PHP DBAccess::QueryAssoc怎么用?PHP DBAccess::QueryAssoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBAccess
的用法示例。
在下文中一共展示了DBAccess::QueryAssoc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_active
function render_active($limit = 5, $alive_only = true)
{
$where_cond = $alive_only ? 'and health>0' : '';
$sel = "select uname, player_id from players where confirmed=1 {$where_cond} order by last_started_attack desc limit {$limit}";
$sql = new DBAccess();
$res = $sql->QueryAssoc($sel);
$out = "\n <div class='active-players'>\n <ul>\n <li><span>Lurking ninja: </span></li>\n\t";
foreach ($res as $ninja) {
$out .= " <li class='active-ninja'><a href='player.php?target_id=" . $ninja['player_id'] . "'>" . $ninja['uname'] . "</a></li>";
}
$out .= "\n </ul>\n </div>\n ";
return $out;
}
示例2: is_authentic
/**
* Just do a check whether the input username and password is valid
* @return boolean
**/
function is_authentic($user, $pass)
{
$filter = new Filter();
$user = $filter->toUsername($user);
$pass = $filter->toPassword($pass);
$res = false;
if ($user != '' && $pass != '') {
$sql = new DBAccess();
$q = "select uname, player_id from players where lower(uname) =\n\t\t\tlower('" . $user . "') and pname = '" . $pass . "' and confirmed = 1 limit 1";
$results = $sql->QueryAssoc($q);
$rows = $sql->getRowCount();
if (1 == $rows) {
$res = true;
}
}
return $res;
}
示例3: render_clan_members
function render_clan_members($clan = null, $limit = 30)
{
ob_start();
if ($clan) {
$where = "where clan = '{$clan}' and confirmed=1";
$sel = "select uname, player_id, health from players {$where} order by health desc, level desc limit {$limit}";
$sql = new DBAccess();
$ninjas = $sql->QueryAssoc($sel);
?>
<div class='clan-members'>
<div class='subtitle'>Clan members</div>
<?php
if (!empty($ninjas)) {
$display_ul = true;
}
if ($display_ul) {
echo "<ul>";
}
foreach ($ninjas as $ninja) {
$added_class = '';
if ($ninja['health'] < 1) {
$added_class = ' injured';
}
echo "<li class='clan-member{$added_class}'>\n <a href='player.php?target_id=" . $ninja['player_id'] . "'>\n " . $ninja['uname'] . "\n </a>\n </li>";
}
if ($display_ul) {
echo "</ul>";
}
?>
</div>
<?php
}
$res = ob_get_contents();
ob_end_clean();
return $res;
}