国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? ??? ?? C#.Net ???? Yii2? ??? ?? ??? ??? ?? ???? ?????.

Yii2? ??? ?? ??? ??? ?? ???? ?????.

Jan 13, 2017 pm 03:53 PM

1. ?? ??

? ???? ? ?? ??? ?????. ?? ???? ???? ?? ???? gii? ??? ? ???, ???? ?? ?? ????. ? ??? ?? ?? ???? ?? ??? ???? ??????. ?? ??? ???? ????.

1. ?? ??? ??

<?php
//...other code
//關(guān)聯(lián)
public function getCate(){
    return $this->hasOne(ArticleCate::className(),[&#39;id&#39; => &#39;cid&#39;]);
  }
?>

2. ?? ??

common/models/search/Create ArticleSearch.php

<?php
 
namespace common\models\search;
 
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Article;
 
class ArticleSearch extends Article
{
  //public $cname;//文章類別名
   
  /**
   * @inheritdoc
   */
  public function rules()
  {
    return [
      [[&#39;cid&#39;,&#39;created_at&#39;, &#39;updated_at&#39;], &#39;integer&#39;],
      [[&#39;id&#39;, &#39;desc&#39;,&#39;title&#39;,&#39;cover&#39;,&#39;content&#39;], &#39;safe&#39;],
    ];
  }
 
  /**
   * @inheritdoc
   */
  public function scenarios()
  {
    // bypass scenarios() implementation in the parent class
    return Model::scenarios();
  }
 
  //搜索
  public function search($params)
  {
    $query = Article::find();
    // $query->joinWith([&#39;cate&#39;]);//關(guān)聯(lián)文章類別表
    // $query->joinWith([&#39;author&#39; => function($query) { $query->from([&#39;author&#39; => &#39;users&#39;]); }]);
 
    $dataProvider = new ActiveDataProvider([
      &#39;query&#39; => $query,
      &#39;pagination&#39; => [
        &#39;pageSize&#39; => 2,
      ],
    ]);
    // 從參數(shù)的數(shù)據(jù)中加載過濾條件,并驗證
    $this->load($params);
 
    if (!$this->validate()) {
      // uncomment the following line if you do not want to any records when validation fails
      // $query->where(&#39;0=1&#39;);
      return $dataProvider;
    }
 
    // 增加過濾條件來調(diào)整查詢對象
    $query->andFilterWhere([
      // &#39;cname&#39; => $this->cate.cname,
      &#39;title&#39; => $this->title,
    ]);
 
    $query->andFilterWhere([&#39;like&#39;, &#39;title&#39;, $this->title]);
    //$query->andFilterWhere([&#39;like&#39;, &#39;cate.cname&#39;, $this->cname]) ;
 
    return $dataProvider;
  }
}

2. ??? ??

?? 1

?? ????? ???? ??? ??? ???? ????. with data :

<?php
//other code
use yii\data\Pagination;
public function actionArticlelist()
  {
    //分頁讀取類別數(shù)據(jù)
    $model = Article::find()->with(&#39;cate&#39;);
    $pagination = new Pagination([
      &#39;defaultPageSize&#39; => 3,
      &#39;totalCount&#39; => $model->count(),
    ]);
 
    $model = $model->orderBy(&#39;id ASC&#39;)
      ->offset($pagination->offset)
      ->limit($pagination->limit)
      ->all();
 
    return $this->render(&#39;index&#39;, [
      &#39;model&#39; => $model,
      &#39;pagination&#39; => $pagination,
    ]);
  }
?>

??, ??? ???? ???? ?? ????? ??? ??? ?? ???? ?????.

<?php
use yii\widgets\LinkPager;
use yii\helpers\Html;
use yii\helpers\Url;
//other code
foreach ($models as $model) {
  // 在這里顯示 $model
}
 
// 顯示分頁
echo LinkPager::widget([
  &#39;pagination&#39; => $pagination,
  &#39;firstPageLabel&#39;=>"First",
  &#39;prevPageLabel&#39;=>&#39;Prev&#39;,
  &#39;nextPageLabel&#39;=>&#39;Next&#39;,
  &#39;lastPageLabel&#39;=>&#39;Last&#39;,
]);
?>

?? 2

????:

<?php
    $query = Article::find()->with(&#39;cate&#39;);
 
    $provider = new ActiveDataProvider([
      &#39;query&#39; => $query,
      &#39;pagination&#39; => [
        &#39;pageSize&#39; => 3,
      ],
      &#39;sort&#39; => [
        &#39;defaultOrder&#39; => [
          //&#39;created_at&#39; => SORT_DESC,
          //&#39;title&#39; => SORT_ASC,
        ]
      ],
    ]);
    return $this->render(&#39;index&#39;, [
      &#39;model&#39; => $query,
      &#39;dataProvider&#39; => $provider
    ]);
?>

??:

<?php
use yii\grid\GridView;
echo GridView::widget([
  &#39;dataProvider&#39; => $dataProvider,
  //每列都有搜索框 控制器傳過來$searchModel = new ArticleSearch();
  //&#39;filterModel&#39; => $searchModel,
  &#39;layout&#39;=> &#39;{items}<div class="text-right tooltip-demo">{pager}</div>&#39;,
   &#39;pager&#39;=>[
        //&#39;options&#39;=>[&#39;class&#39;=>&#39;hidden&#39;]//關(guān)閉自帶分頁
        &#39;firstPageLabel&#39;=>"First",
        &#39;prevPageLabel&#39;=>&#39;Prev&#39;,
        &#39;nextPageLabel&#39;=>&#39;Next&#39;,
         &#39;lastPageLabel&#39;=>&#39;Last&#39;,
   ],
  &#39;columns&#39; => [
    //[&#39;class&#39; => &#39;yii\grid\SerialColumn&#39;],//序列號從1開始
    // 數(shù)據(jù)提供者中所含數(shù)據(jù)所定義的簡單的列
    // 使用的是模型的列的數(shù)據(jù)
    &#39;id&#39;,
    &#39;username&#39;,
    [&#39;label&#39;=>&#39;文章類別&#39;, /*&#39;attribute&#39; => &#39;cid&#39;,產(chǎn)生一個a標簽,點擊可排序*/ &#39;value&#39; => &#39;cate.cname&#39; ],
    [&#39;label&#39;=>&#39;發(fā)布日期&#39;,&#39;format&#39; => [&#39;date&#39;, &#39;php:Y-m-d&#39;],&#39;value&#39; => &#39;created_at&#39;],
    // 更復(fù)雜的列數(shù)據(jù)
    [&#39;label&#39;=>&#39;封面圖&#39;,&#39;format&#39;=>&#39;raw&#39;,&#39;value&#39;=>function($m){
     return Html::img($m->cover,[&#39;class&#39; => &#39;img-circle&#39;,&#39;width&#39; => 30]);
    }],
    [
      &#39;class&#39; => &#39;yii\grid\DataColumn&#39;, //由于是默認類型,可以省略
      &#39;value&#39; => function ($data) {
        return $data->name;
        // 如果是數(shù)組數(shù)據(jù)則為 $data[&#39;name&#39;] ,例如,使用
 
SqlDataProvider 的情形。
      },
    ],
    [
     &#39;class&#39; => &#39;yii\grid\ActionColumn&#39;,
     &#39;header&#39; => &#39;操作&#39;,
     &#39;template&#39; => &#39;{delete} {update}&#39;,//只需要展示刪除和更新
     /*&#39;headerOptions&#39; => [&#39;width&#39; => &#39;80&#39;],*/
     &#39;buttons&#39; => [
       &#39;delete&#39; => function($url, $model, $key){
           return Html::a(&#39;<i class="glyphicon glyphicon-trash"></i> 刪除&#39;,
               [&#39;artdel&#39;, &#39;id&#39; => $key],
               [&#39;class&#39; => &#39;btn btn-default btn-xs&#39;,
               &#39;data&#39; => [&#39;confirm&#39; => &#39;你確定要刪除文章嗎?&#39;,]
               ]);
       },
      &#39;update&#39; => function($url, $model, $key){
           return Html::a(&#39;<i class="fa fa-file"></i> 更新&#39;,
              [&#39;artedit&#39;, &#39;id&#39; => $key],
              [&#39;class&#39; => &#39;btn btn-default btn-xs&#39;]);
       },
      ],
     ],
  ],
]);
?>

3. ??? ???? ??

?? ?? ??(??? ???)

?? ??? ??

?? ?? ???? ??:

<?php
public function actionIndex()
{
 $searchModel = new ArticleSearch();
 $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
 
  return $this->render(&#39;index&#39;, [
    &#39;searchModel&#39; => $searchModel,
    &#39;dataProvider&#39; => $dataProvider,
  ]);
 }
?>

??:

<?php $form = ActiveForm::begin([
  &#39;action&#39; => [&#39;index&#39;],
   &#39;method&#39; => &#39;get&#39;,
   &#39;id&#39; => &#39;cateadd-form&#39;,
   &#39;options&#39; => [&#39;class&#39; => &#39;form-horizontal&#39;],
]); ?>
           
<?= $form->field($searchModel, &#39;title&#39;,[
   &#39;options&#39;=>[&#39;class&#39;=>&#39;&#39;],
   &#39;inputOptions&#39; => [&#39;placeholder&#39; => &#39;文章搜索&#39;,&#39;class&#39; => &#39;input-sm form-control&#39;],
])->label(false) ?>
  <?= Html::submitButton(&#39;Go!&#39;, [&#39;class&#39; => &#39;btn btn-sm btn-primary&#39;]) ?>
<?php ActiveForm::end(); ?>
<?= GridView::widget([
          &#39;dataProvider&#39; => $dataProvider,
          &#39;layout&#39;=> &#39;{items}<div class="text-right tooltip-demo">{pager}</div>&#39;,
          &#39;pager&#39;=>[
            //&#39;options&#39;=>[&#39;class&#39;=>&#39;hidden&#39;]//關(guān)閉自帶分頁
            &#39;firstPageLabel&#39;=>"First",
            &#39;prevPageLabel&#39;=>&#39;Prev&#39;,
            &#39;nextPageLabel&#39;=>&#39;Next&#39;,
            &#39;lastPageLabel&#39;=>&#39;Last&#39;,
          ],
       //這部分和上面的分頁是一樣的

? ??? ??? ??? ??? ??? ????. . ?? ?? ??? PHP ???? ????? ????.

? ?? ??? ??, ??? ?? ??? ?? ? ?? ??? ??? PHP ??? ????? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

?? ????
1783
16
Cakephp ????
1728
56
??? ????
1579
28
PHP ????
1444
31
???
??? ????? C#? ?? ???? ???? ?????? ??? ????? C#? ?? ???? ???? ?????? Jun 19, 2025 am 12:17 AM

theieldKeyWordinc#simplifiesteratorcreationBeycreationSomateAtAtAtenablesLazyEvaluation.1.ItAllOwSreturningItemSoneatAtimeUsingyieldRetrern, weeneachitem, 2.yieldBreenceCanbeus

??? ?? (DI)?? ???? C# (? : ASP.NET Core?? ?? DI? ???? ??? ??? ? ?????)? ??? ??? ? ????? ??? ?? (DI)?? ???? C# (? : ASP.NET Core?? ?? DI? ???? ??? ??? ? ?????)? ??? ??? ? ????? Jun 30, 2025 am 02:06 AM

DependencyInjection(DI)inC#isadesignpatternthatenhancesmodularity,testability,andmaintainabilitybyallowingclassestoreceivedependenciesexternally.1.DIpromotesloosecouplingbydecouplingobjectcreationfromusage.2.Itsimplifiestestingthroughmockobjectinject

?? ????? idisposable ?????? C#? ?? ???? ??? ?????? ?? ????? idisposable ?????? C#? ?? ???? ??? ?????? Jun 27, 2025 am 02:18 AM

C#?? idisposable? ??? ??? ???? ?? ???? ????? ????? ???? ????. 1. idisposable? dispose () ???? ???? ???? ???? ?? ???? ???? ??? ???? ?? ? ? ???; 2. ?? ???? ??? ??? ??? ?? Dispose ()? ???? ????? ???? ??? ??? ????? ??? ?????. 3.?? ??? ? ??? idisposable? ???? ?? ??? ?? ? ? ??? StreamReader? ?? ??? ?? ???????. 4. ???? ?? ???? ??, ?? ? ??? ???? ???? Dispose (BOOL) ??? ???? ?? ???? ???? ?? ?? ?????.

Lambda Expressions and LINQ (Language Integrated Query)? C#? ??? ??? ??? ?? ????? Lambda Expressions and LINQ (Language Integrated Query)? C#? ??? ??? ??? ?? ????? Jun 20, 2025 am 12:16 AM

lambdaexpressionsandlinqsimplifydatamanipulationinc#byenablingconcise, ?? ?? ? ???? ??

C# 8? ?? ?? ?? (NRT)?? ???? NullReferenceException? ???? ? ??? ??????? C# 8? ?? ?? ?? (NRT)?? ???? NullReferenceException? ???? ? ??? ??????? Jun 21, 2025 am 12:36 AM

NULLABLEREFERENCETYPES (NRTS) INC#8 HELPCATCHNULLREFERNEEXCEPTIONERCECTIONPILETIMEBYMAKINGERENCETYPESNON-NULLABLEBYDEFAULT.NURTSMUSTBEEBEDITHERINTHETHETHE.CSPROJFILEWITHENORATTETTETOPA.CSFILESOUN NULL

C#? ??? ? ?? ??? ???? ???? ?? ?? ??? ?????? C#? ??? ? ?? ??? ???? ???? ?? ?? ??? ?????? Jun 23, 2025 am 12:05 AM

C# ???? 4 ?? ???? "??"??? ??????. ??, ???/???? ????? ??? ?? ?? ? ?? ??? ?????. ??? ?? ????? ??? ????, configureawait (false)? ???? ??? ????????. ??, VAR? ?? ??? ???? ???? ??? ??? ??? ??? ? ? ? ??? ?? ??? ???? ?????. ??, ?? ? ?? ??? ?? ???? ??? ???? ?? ???? ???? ?????? IDISPosable ?? ??? ?????????. ??, ?? ??? ?? ?? ?? ???? ?? ??? ???? ???? ??? ??, ? ?? ?? ????? ???? ????? ?? ??? ????????. ??? ??? ??? ?? ??? ?? ??? ?? ?? ? ? ????.

C#? SPAN ? ??? ? ???? ??? ???? ????? ??? ?? ??? ??? ?????? C#? SPAN ? ??? ? ???? ??? ???? ????? ??? ?? ??? ??? ?????? Jun 18, 2025 am 12:11 AM

?? ? ???? ??? ??? ????? C# ??? ??????. 1. ??? ?? ??? ??? ?? ???? ?? ??? ??? ????, ?? ?? ????, ??? ?? ? ??? ?? ??? ?????. 2. ???? ??? ??? ?? ??? ????? ???? ?? ????, ?? ? ??? ????? ??? ????? ?????. 3. ? ? GC ??? ??? ??? ????? ?? ??? ????? ??? ??????. 4. SPAN? ???? ???? ??? ???? ???? ????? ??? ???? ??? ? ????. Calling.toArray ()? ?? ? ?? ??? ??? ????????.

C# ?? ?? ????? ??? ??? ?? ????? ?? ? ? ????? C# ?? ?? ????? ??? ??? ?? ????? ?? ? ? ????? Jun 25, 2025 am 12:47 AM

??? ??? ?? ?? ?????? ?? ?? ?? ? ?? ?? ??????? 5 ?? ?? ?????. 1. SRP (Single Responsibility Principle)? ???? ??? ?? ?? ? ??? ??? ?? ??? ?? ? ????? ?????. 2. OCP (Opening and Closing Principle)? ISHAPE ?????? ???? ?? ???? ?? ??? ???? ?? ?? ?? ??? ???? ?? ????? ?? ?? ???? ?? ??? ????? ?? ?????. 3. Richter ?? ?? (LSP)? ?? ???? ??? ???? ?? ?? ???? ?? ? ? ??????. 4. ISP (Interface Displence Principle)? ?? ???? ??? ?? ?? ?? ? ?? ??? ?? ??? ?????? ??? ?????. 5. ??? ?? ?? (DIP)?

See all articles