当前位置: 首页>>代码示例>>PHP>>正文


PHP Forum::find_by_id方法代码示例

本文整理汇总了PHP中Forum::find_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Forum::find_by_id方法的具体用法?PHP Forum::find_by_id怎么用?PHP Forum::find_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Forum的用法示例。


在下文中一共展示了Forum::find_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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'));
 }
开发者ID:visavi,项目名称:rotorcms,代码行数:34,代码来源:ForumController.php

示例2: edit_topic

 public function edit_topic(Request $request, $matches)
 {
     $title = $this->lang->translate('forum.create');
     // Get page for updating
     $id = intval($matches->get('id', $request->get('id')));
     // Parent topic
     $topics = \Forum::as_array(\Forum::find('all', ['conditions' => ['forum_id = 0 AND id <> ?', $id]]));
     if ($id > 0) {
         $forum = \Forum::find_by_id($id);
         $title = $this->lang->translate('forum.editing', $forum->title);
     } else {
         $forum = ['title' => $this->lang->translate('page.name'), 'forum_id' => null];
     }
     // Create or update page
     if ($request->isMethod('post')) {
         if ($forum instanceof \Forum) {
             $forum->title = $request->get('title');
             $forum->forum_id = $request->get('forum');
             $forum->author_id = $this->user->id;
         } else {
             $forum = new \Forum(['title' => $request->get('title'), 'forum_id' => $request->get('forum'), 'author_id' => $this->user->id]);
         }
         // Updating instance
         $forum->save();
         $forum = $forum->to_array();
         return static::json_response(['success' => true, 'message' => $this->lang->translate('form.saved')]);
     }
     return $this->view->render('forum/create.twig', ['forum' => $forum, 'title' => $title, 'topics' => $topics]);
 }
开发者ID:Max201,项目名称:nanocore,代码行数:29,代码来源:Control.php


注:本文中的Forum::find_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。