示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Ads::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, 'place' => $this->place, 'ord' => $this->ord, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'thumb', $this->thumb])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'intro', $this->intro])->andFilterWhere(['like', 'url', $this->url]);
     return $dataProvider;
 }
示例#2
0
 /**
  * Finds the Ads model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Ads the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Ads::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#3
0
        <?php 
foreach ($friendlink as $k => $v) {
    ?>
        <a href="<?php 
    echo $v->link;
    ?>
" target="_blank"><span>建材网</span></a>
        <?php 
}
?>
     
    </div>
    </div>
    <div class="ad01">
        <?php 
$ads = \common\models\Ads::find()->where(['id' => 2])->one();
if ($ads) {
    ?>
        <a href="<?php 
    echo $ads->url;
    ?>
" target="_blank"><img src="<?php 
    echo $ads->thumb;
    ?>
" width="1170" height="69" alt=""></a>
            <?php 
}
?>
    </div>
</div>
<?php