本文整理匯總了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">