當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。