コード例 #1
0
 protected function findModel($id)
 {
     if (($model = FileDownload::find()->where(['and', 'id=' . $id])->One()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('你所查找的网页不存在');
     }
 }
コード例 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = FileDownload::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'filepath', $this->filepath]);
     return $dataProvider;
 }
コード例 #3
0
 * @author Lmy
 * QQ:6232967
 * Create at 2015-12-30 17:47:31
 */
?>
<div class="rmzt">
    <div class="rmzt-tit lm-tb"><span><a href="<?php 
echo Yii::$app->urlManager->createUrl(['file-download/index']);
?>
">更多</a></span>资料下载</div>	
    <div><img src="<?php 
echo Yii::$app->params['staticsPath'];
?>
images/yubin_58.jpg" width="286" height="101" alt=""/></div>
    <ul class="kbxx-nr">
        <?php 
$wenjian = \common\models\FileDownload::find()->orderBy(['created_at' => SORT_DESC])->limit(5)->all();
foreach ($wenjian as $k => $v) {
    ?>
        <li><a href="<?php 
    echo Yii::$app->urlManager->createUrl(['file-download/index', 'id' => $v->id]);
    ?>
"><?php 
    echo $v->title;
    ?>
</a></li>
        <?php 
}
?>
    </ul>	
</div>  
コード例 #4
0
 /**
  * Finds the FileDownload model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return FileDownload the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = FileDownload::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }