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


PHP News::find_by_id方法代码示例

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


在下文中一共展示了News::find_by_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show

 public function show($id = null)
 {
     $tag = self::load_tag($id);
     $this->assign("tag", $tag);
     $page = 1;
     if (isset($_GET['page'])) {
         $page = $_GET['page'];
     }
     $tag_id = mysql_real_escape_string($tag->id);
     $news = NewsTag::paginate("tags.id = '{$tag_id}'", $page, 10);
     $items = array();
     foreach ($news->collection as $newsitem) {
         $items[] = News::find_by_id($newsitem->news->id);
     }
     $news->collection = $items;
     $this->assign("page", $news);
     $this->title = "View Tag";
     $this->render("tag/show.tpl");
 }
开发者ID:ItsHaden,项目名称:epicLanBootstrap,代码行数:19,代码来源:tag.controller.php

示例2: createComment

 /**
  * Создание комментария
  */
 public function createComment($id)
 {
     if (!($news = News::find_by_id($id))) {
         App::abort('default', 'Данной новости не существует!');
     }
     $comment = new Comment();
     $comment->token = Request::input('token', true);
     $comment->user_id = User::get('id');
     $comment->relate_type = 'News';
     $comment->relate_id = $news->id;
     $comment->text = Request::input('text');
     $comment->ip = App::getClientIp();
     $comment->brow = App::getUserAgent();
     if ($comment->save()) {
         App::setFlash('success', 'Сообщение успешно добавлено!');
     } else {
         App::setFlash('danger', $comment->getErrors());
         App::setInput($_POST);
     }
     App::redirect('/news/' . $id);
 }
开发者ID:visavi,项目名称:rotorcms,代码行数:24,代码来源:NewsController.php

示例3: tags

 public function tags($tag = null)
 {
     $tag = self::load_tag($tag);
     $page = 1;
     if (isset($_GET['page'])) {
         $page = $_GET['page'];
     }
     $tag_id = mysql_real_escape_string($tag->id);
     $news = NewsTag::paginate("tags.id = '{$tag_id}' AND news.published = true AND news.publish_at < NOW()", "news.publish_at DESC", $page, 10);
     $items = array();
     foreach ($news->collection as $newsitem) {
         $item = News::find_by_id($newsitem->news->id);
         if (!$item) {
             continue;
         }
         $items[] = $item;
     }
     $news->collection = $items;
     $this->assign("page", $news);
     $this->assign("tag", $tag);
     $this->title = "News :: {$tag->tag}";
     $this->render("news/tags.tpl");
 }
开发者ID:ItsHaden,项目名称:epicLanBootstrap,代码行数:23,代码来源:news.controller.php


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