本文整理汇总了PHP中DBAccess::fetchAll方法的典型用法代码示例。如果您正苦于以下问题:PHP DBAccess::fetchAll方法的具体用法?PHP DBAccess::fetchAll怎么用?PHP DBAccess::fetchAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBAccess
的用法示例。
在下文中一共展示了DBAccess::fetchAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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><<a href='player.php?player_id={$messageData['sender_id']}'\n\t\t target='main'>{$messageData['uname']}</a>> " . 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;
}