本文整理汇总了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));
}