本文整理匯總了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));
}
示例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]);
}
示例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()));
}
示例4: actionIndex
/**
* Lists all models.
*/
public function actionIndex()
{
$model = new News('search');
$model->unsetAttributes();
$this->render('index', array('dataProvider' => $model->search()));
}
示例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));
}