本文整理汇总了PHP中Topic::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::count方法的具体用法?PHP Topic::count怎么用?PHP Topic::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topic
的用法示例。
在下文中一共展示了Topic::count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forum
/**
* Список тем
*/
public function forum($id)
{
if (!($forum = Forum::find_by_id($id))) {
App::abort('default', 'Данного раздела не существует!');
}
$total = Topic::count(['conditions' => ['forum_id = ?', $id]]);
$page = App::paginate(Setting::get('topics_per_page'), $total);
$topics = Topic::all(['conditions' => ['forum_id = ?', $id], 'offset' => $page['offset'], 'limit' => $page['limit'], 'order' => 'updated_at desc', 'include' => ['forum', 'post_count', 'post_last' => ['user']]]);
/* $topics = Topic::all([
'select' => 't.*, p.user_id post_user, p.created_at post_created',
'from' => 'topics as t',
'conditions' => ['t.forum_id = ?', $id],
'joins' => ['LEFT JOIN (
SELECT topic_id, MAX(created_at) AS max FROM posts
GROUP BY topic_id
) AS latest ON t.id = latest.topic_id
LEFT JOIN posts p ON p.created_at = latest.max
AND p.topic_id = latest.topic_id'],
'offset' => $page['offset'],
'limit' => $page['limit'],
'order' => 't.updated_at desc',
'include' => [
'forum',
'post_count',
],*/
$crumbs = ['/forum' => 'Форум', $forum->title];
if ($forum->parent_id) {
$crumbs = ['/forum' => 'Форум', '/forum/' . $forum->parent_id => $forum->parent()->title, $forum->title];
}
App::view('forums.forum', compact('forum', 'topics', 'page', 'crumbs'));
}
示例2: forumCount
/**
* Количество сообщений в форума
* @return integer сообщений в форуме
*/
function forumCount()
{
return Topic::count() . '/' . Post::count();
}
示例3: onUnSubscribe
/**
* A request to unsubscribe from a topic has been made.
*
* @param \Ratchet\ConnectionInterface $conn
* @param string|Topic $topic The topic to unsubscribe from
*/
public function onUnSubscribe(ConnectionInterface $conn, $topic)
{
$this->console->info("onUnSubscribe: topic: {$topic} {$topic->count()}");
}