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


PHP News::find方法代码示例

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


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

示例1: news_show

function news_show()
{
    global $news_show;
    $news = new News();
    $news_show = $news->find($_GET['id']);
    render();
}
开发者ID:bjcpgd,项目名称:palserve,代码行数:7,代码来源:news.php

示例2: removeNews

 public function removeNews($id)
 {
     $news = News::find($id);
     $name = $news->title;
     $news->delete();
     return Redirect::route('account')->with('status', 'alert-success')->with('global', 'You just deleted ' . $name);
 }
开发者ID:mlauren,项目名称:midway-gallery,代码行数:7,代码来源:NewsController.php

示例3: togglePublish

 /**
  * @param $id
  * @return mixed
  */
 public function togglePublish($id)
 {
     $news = $this->news->find($id);
     $news->is_published = $news->is_published ? false : true;
     $news->save();
     return Response::json(array('result' => 'success', 'changed' => $news->is_published ? 1 : 0));
 }
开发者ID:phillipmadsen,项目名称:app,代码行数:11,代码来源:NewsRepository.php

示例4: Insert_UpdateNews

 public function Insert_UpdateNews($data)
 {
     $id = Input::get("id");
     if (!Input::has('id')) {
         $news = new News();
     } else {
         $news = News::find(array_get($data, 'id'));
         //tìm id đã có trong data
     }
     $news->title = array_get($data, 'title');
     // Upload images
     if (Input::file('file')) {
         define('PATH_CATEGORY_ICON', rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/upload/');
         $file = array_get($data, 'file');
         $file->move(PATH_CATEGORY_ICON, $file->getClientOriginalName());
         $news->images = $file->getClientOriginalName();
     }
     // End Upload images
     $news->tomtat = array_get($data, 'tomtat');
     $news->content = array_get($data, 'content');
     $news->cat_id = array_get($data, 'cat_id');
     $news->hot = array_get($data, 'hot');
     $news->ngaydangbai = date('Y-m-d H:i:s');
     return $news->save();
 }
开发者ID:vudinhkien,项目名称:AdminBlog,代码行数:25,代码来源:News.php

示例5: listAction

 public function listAction()
 {
     $params = $this->request->getQuery();
     if ($params['_url'] != null) {
         $string = ltrim($params['_url'], '/danh-muc');
     }
     $array = explode('-', $string);
     $id = $array[0];
     // Get name category
     $category = Category::findFirstById($id);
     $this->tag->setTitle($category->name);
     // Get list category of id
     if ($id != '' && $id > 0) {
         // The data set to paginate
         $news = News::find(array('active = 1 AND category =' . $id, 'order' => 'id DESC'));
         $currentPage = (int) $_GET["page"];
         // Create a Model paginator, show 10 rows by page starting from $currentPage
         $paginator = new PaginatorModel(array("data" => $news, "limit" => 13, "page" => $currentPage));
         // Get the paginated results
         $page = $paginator->getPaginate();
         $this->view->setVar('page', $page);
         $this->view->setVar('category', $category);
     } else {
         $this->response->redirect('error');
     }
 }
开发者ID:JosTrucD,项目名称:phalcon-news,代码行数:26,代码来源:IndexController.php

示例6: testEmpty

 public function testEmpty()
 {
     $news = News::find();
     $this->assertTrue($news->count() == 0);
     $news = new News();
     $news->title = "A new News!";
     $this->assertFalse($news->save());
 }
开发者ID:BackupTheBerlios,项目名称:medick-svn,代码行数:8,代码来源:ValidatorTest.php

示例7: showYearAction

 public function showYearAction()
 {
     $activeYear = $this->filter->sanitize($this->_getParam('year'), "int");
     Phalcon_Tag::setTitle('News');
     $this->view->setVar("news", News::find(array("year='{$activeYear}'", "order" => "published DESC")));
     $this->view->setVar("activeYear", $activeYear);
     $this->view->setVar("years", News::count(array('group' => 'year')));
 }
开发者ID:risavkarna,项目名称:php-site,代码行数:8,代码来源:NewsController.php

示例8: get_detail

 public function get_detail($id)
 {
     $news = News::find($id);
     if (is_null($news)) {
         return json_encode('News not found', 404);
     } else {
         return json_encode($news);
     }
 }
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:9,代码来源:news.php

示例9: hasUpdated

 public function hasUpdated()
 {
     $checksum = News::find()->select('SUM(`publishDate`)')->where(['or', ['in', 'categoryID', $this->categories], ['in', 'id', $this->articles]])->scalar();
     if (\Yii::$app->cache->get('rssfeed-' . $this->id . '-checksum') != $checksum) {
         \Yii::$app->cache->set('rssfeed-' . $this->id . '-checksum', $checksum);
         return true;
     }
     return false;
 }
开发者ID:BoBRoID,项目名称:new.k-z,代码行数:9,代码来源:NewsFeed.php

示例10: post_delete

 public function post_delete($id)
 {
     $news = News::find($id);
     if (empty($news)) {
         return View::make('msg.error')->with('error', 'That news item doesn\'t exist.');
     }
     $news->delete();
     return Redirect::to('/admin/news/overview');
 }
开发者ID:albertpaulp,项目名称:PrettyBoot,代码行数:9,代码来源:news.php

示例11: get_delete

 public function get_delete($id = false)
 {
     if (!$id) {
         return Redirect::to('news');
     }
     $news = News::find($id);
     $news->delete();
     return Redirect::to('news');
 }
开发者ID:acmadi,项目名称:diantaksi,代码行数:9,代码来源:news.php

示例12: indexAction

 public function indexAction()
 {
     $language = Phalcon_Session::get('language');
     $news = News::find(array("language='{$language}'", "limit" => 5, "order" => "published desc"));
     if (count($news) === 0) {
         $news = News::find(array("language='en'", "limit" => 5, "order" => "published desc"));
     }
     //Query the last 5 news
     $this->view->setVar("news", $news);
 }
开发者ID:risavkarna,项目名称:php-site,代码行数:10,代码来源:IndexController.php

示例13: destroy

 public function destroy($id, $request)
 {
     $data = ['success' => false];
     if (News::exists($id)) {
         $new = News::find($id);
         if ($new->belongsToUser(Session::get())) {
             $data['success'] = $new->delete();
         }
     }
     return new JsonResponse($data);
 }
开发者ID:agiza,项目名称:DreamVids,代码行数:11,代码来源:news_controller.php

示例14: index

    function index() {
        $recent_events = Event::find()->where(array('created_at >= NOW() - INTERVAL 1 WEEK'))->order('created_at DESC')->all();

        $find_news = News::find()
            ->order(array('weight ASC', 'updated_at DESC'))
            ->limit(5);

        $this->render(array(
            'recent_events' => $recent_events,
            'news' => $find_news->all(),
        ));
    }
开发者ID:reddragon010,项目名称:RG-ServerPanel,代码行数:12,代码来源:HomeController.php

示例15: showSinglePressItem

 public function showSinglePressItem($slug, $id)
 {
     $pressItem = News::with('catalog')->find($id);
     if (!$pressItem || !$pressItem->isActive() || $pressItem->getSlug() != $slug) {
         App::abort(404);
     }
     $previousPressItemId = News::active()->where('id', '<', $pressItem->id)->max('id');
     $previousPressItem = News::find($previousPressItemId);
     $nextPressItemId = News::active()->where('id', '>', $pressItem->id)->min('id');
     $nextPressItem = News::find($nextPressItemId);
     return View::make('about.press.single', compact('pressItem', 'previousPressItem', 'nextPressItem'));
 }
开发者ID:OlesKashchenko,项目名称:SkillsProject1,代码行数:12,代码来源:AboutController.php


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