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


PHP Article::query方法代码示例

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


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

示例1: function

                }
            });
        }
    });
JS
);
?>

<div class="container">
    <div class="page-header">
        <h1>Статьи</h1>
    </div>


    <?php 
echo \yii\grid\GridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => \app\models\Article::query()->orderBy(['date_insert' => SORT_DESC]), 'pagination' => ['pageSize' => 20]]), 'columns' => ['id', ['header' => 'Картинка', 'content' => function ($item) {
    if ($item['image']) {
        return Html::a(Html::img($item['image'], ['class' => 'thumbnail', 'width' => 80, 'style' => 'margin-bottom: 0px;']), ['admin_article/edit', 'id' => $item['id']]);
    } else {
        if ($item['video']) {
            $video = $item['video'];
            $video = new \cs\services\Url($video);
            $video = explode('/', $video);
            $video = $video[count($video) - 1];
            return Html::a($video, ['admin_article/edit', 'id' => $item['id']]);
        }
    }
}], ['header' => 'Название', 'content' => function ($item) {
    return Html::a($item['header'], ['admin_article/edit', 'id' => $item['id']]);
}], 'date_insert:datetime:Дата добавления', ['header' => 'Удалить', 'content' => function ($item) {
    return Html::button('Удалить', ['class' => 'btn btn-danger btn-xs buttonDelete', 'data-id' => $item['id']]);
开发者ID:dram1008,项目名称:gleb,代码行数:31,代码来源:index.php

示例2: actionSearch

 public function actionSearch()
 {
     $term = self::getParam('term');
     $items = Article::query(['like', 'content', $term])->orWhere(['like', 'header', $term])->all();
     return $this->render(['list' => $items]);
 }
开发者ID:dram1008,项目名称:gleb,代码行数:6,代码来源:SiteController.php

示例3: DateTime

                    <input type="text" name="term" value="Введите слово ..." onFocus="this.value=''"
                           onBlur="this.value='Введите слово ...'"/>
                </form>
            </div>

        </div>
        <!-- #first .widget-area -->

        <div id="second" class="widget-area">
            <div class="widget widget_archive">
                <h3 class="widget-title">Архивы</h3>
                <?php 
$min = \app\models\Article::query()->select('min(date_insert)')->scalar();
$dateMin = new DateTime($min);
$dateNow = new DateTime();
$rows = \app\models\Article::query()->select(['count(*) as c1', 'YEAR(date) as year', 'MONTH(date) as month'])->groupBy(['YEAR(date)', 'MONTH(date)'])->orderBy(['YEAR(date)' => SORT_DESC, 'MONTH(date)' => SORT_DESC])->all();
/** @var int $max максиальный месяц с годом  1-12 */
$max = $rows[0]['year'] * 12 + ($rows[0]['month'] - 1);
$min = $rows[count($rows) - 1]['year'] * 12 + ($rows[count($rows) - 1]['month'] - 1);
?>
                <ul>
                    <?php 
for ($i = $max; $i >= $min; $i--) {
    ?>
                        <?php 
    $month = $i % 12;
    if ($month == 0) {
        $month = 11;
    }
    $monthZero = $month + 1;
    if ($monthZero < 10) {
开发者ID:dram1008,项目名称:gleb,代码行数:31,代码来源:landing.php

示例4: actionArticle

 public function actionArticle($category, $year, $month, $day, $id)
 {
     $item = Article::find(['id_string' => $id, 'DATE(date_insert)' => $year . $month . $day]);
     if (is_null($item)) {
         throw new Exception('Нет такой статьи');
     }
     $categoryObject = UnionCategory::find(['id_string' => $category]);
     $item->incViewCounter();
     $nearList = Article::getByTreeNodeIdQuery($categoryObject->getId())->andWhere(['not in', 'id', $item->getId()])->limit(3)->all();
     if (count($nearList) == 0) {
         $nearList = Article::query()->select('id,header,id_string,image,view_counter,description,content,date_insert')->orderBy(['date_insert' => SORT_DESC])->andWhere(['not in', 'id', $item->getId()])->limit(3)->all();
     }
     return $this->render(['item' => $item->getFields(), 'category' => $category, 'nearList' => $nearList, 'breadcrumbs' => $categoryObject->getBreadCrumbs([$item->getField('header')])]);
 }
开发者ID:Makeyko,项目名称:galaxysss,代码行数:14,代码来源:PageController.php

示例5: actionIndex

 public function actionIndex()
 {
     return $this->render(['items' => Article::query()->orderBy(['date_insert' => SORT_DESC])->all()]);
 }
开发者ID:Makeyko,项目名称:galaxysss,代码行数:4,代码来源:Admin_articleController.php


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