當前位置: 首頁>>代碼示例>>PHP>>正文


PHP News::search方法代碼示例

本文整理匯總了PHP中News::search方法的典型用法代碼示例。如果您正苦於以下問題:PHP News::search方法的具體用法?PHP News::search怎麽用?PHP News::search使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在News的用法示例。


在下文中一共展示了News::search方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionIndex

 public function actionIndex()
 {
     $model = new News('search');
     $model->unsetAttributes();
     if (isset($_GET['News'])) {
         $model->setAttributes($_GET['News']);
     }
     $dataProvider = $model->search();
     $this->render('//news/index', array('dataProvider' => $dataProvider, 'model' => $model));
 }
開發者ID:mmorpg2015,項目名稱:ghtweb5,代碼行數:10,代碼來源:NewsController.php

示例2: actionList

 public function actionList()
 {
     $this->breadcrumbs[] = array('title' => "Новости", 'url' => $this->createUrl("list"));
     $this->Title = "Новости";
     $model = new News("search");
     if (!empty($_GET['filter'])) {
         $model->attributes = $_GET['filter'];
     }
     $dataProvider = $model->search();
     $this->render("list", ["dP" => $dataProvider]);
 }
開發者ID:CrystReal,項目名稱:Site_frontend,代碼行數:11,代碼來源:NewsController.php

示例3: actionIndex

 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $this->pageTitle = Yii::t('titles', 'NEWS_NEWS');
     $model = new News('search');
     $model->unsetAttributes();
     $this->render('index', array('dataProvider' => $model->search()));
 }
開發者ID:snipesn,項目名稱:UkrYama-2,代碼行數:10,代碼來源:NewsController.php

示例4: actionIndex

 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $model = new News('search');
     $model->unsetAttributes();
     $this->render('index', array('dataProvider' => $model->search()));
 }
開發者ID:ASDAFF,項目名稱:RosYama.2,代碼行數:9,代碼來源:NewsController.php

示例5: search

 /**
  * @test
  */
 public function search()
 {
     $model = new News('search');
     $model->unsetAttributes();
     // recherche par date
     $model->unsetAttributes();
     $model->event_date = "01/06/2013";
     $data = $model->search()->data;
     $this->assertEquals(1, count($data));
     $this->assertEquals($this->news('n1')->id, $data[0]->id);
     // recherche par statut
     $model->unsetAttributes();
     $model->enabled = 0;
     $data = $model->search()->data;
     $this->assertEquals(1, count($data));
     // recherche par catégorie
     $model->unsetAttributes();
     $categoryId = 1;
     // la plupart des news sont de cette catégorie
     $model->category_id = $categoryId;
     $count = Yii::app()->db->createCommand("SELECT count(*) as cpt FROM news WHERE category_id = {$categoryId}")->queryScalar();
     $this->assertEquals($count, count($model->search()->data));
     $model->unsetAttributes();
     $categoryId = 2;
     // il y a quelques news de cette catégorie
     $model->category_id = $categoryId;
     $count = Yii::app()->db->createCommand("SELECT count(*) as cpt FROM news WHERE category_id = {$categoryId}")->queryScalar();
     $this->assertEquals($count, count($model->search()->data));
     $model->unsetAttributes();
     $categoryId = 99;
     // aucune news de cette catégorie
     $model->category_id = $categoryId;
     $count = Yii::app()->db->createCommand("SELECT count(*) as cpt FROM news WHERE category_id = {$categoryId}")->queryScalar();
     $this->assertEquals($count, count($model->search()->data));
 }
開發者ID:ChristopheBrun,項目名稱:hLib,代碼行數:38,代碼來源:NewsTest.php


注:本文中的News::search方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。