本文整理汇总了PHP中WCF::getAuthorById方法的典型用法代码示例。如果您正苦于以下问题:PHP WCF::getAuthorById方法的具体用法?PHP WCF::getAuthorById怎么用?PHP WCF::getAuthorById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WCF
的用法示例。
在下文中一共展示了WCF::getAuthorById方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
header('Content-type: application/json');
if (!$CURUSER->isOnline()) {
$error = 'You must be logged in!';
}
$PostId = isset($_GET['id']) ? (int) $_GET['id'] : false;
if ($PostId === false) {
$error = 'Invalid post id.';
}
//Validate the post
$res = $DB->prepare("SELECT * FROM `wcf_posts` WHERE `id` = :id LIMIT 1;");
$res->bindParam(':id', $PostId, PDO::PARAM_INT);
$res->execute();
if ($res->rowCount() == 0) {
$error = 'Invalid post id.';
}
//check for errors
if (!$error) {
//Fetch the post data
$Post = $res->fetch();
if ($author = WCF::getAuthorById($Post['author'])) {
$Post['author_str'] = $author;
} else {
$Post['author_str'] = 'Unknown';
}
unset($author);
$data = array('text' => $Post['text'], 'author' => $Post['author_str']);
echo json_encode($data);
} else {
echo json_encode(array('error' => $error));
}
unset($res);
示例2: while
', $pages['next'], '
</ul>';
}
echo '
</div>
<!-- Actions.End -->';
}
echo '
<!--<ul class="topic_header">
<li class="topic">Topic</li>
<li class="lastpost">Last post</li>
</ul>-->';
if ($countOnPage > 0) {
//loop the records
while ($arr = $topics_res->fetch()) {
if ($author = WCF::getAuthorById($arr['author'])) {
$arr['author_str'] = $author;
} else {
$arr['author_str'] = 'Unknown';
}
unset($author);
//format the time
$arr['added'] = date('D M j, Y, h:i a', strtotime($arr['added']));
//Get the last post
$lastPost = WCF::getTopicLastPost($arr['id']);
echo '
<ul class="topic_row">
<li class="icon">
<img src="template/forums/style/icons/topic_unread_mine.png" width="55px" height="39px"/>
</li>
<li class="topic_title_by_date">