當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。