示例#1
0
 public function search($params)
 {
     $query = Music::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['Id' => $this->Id, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy, 'createdOn' => $this->createdOn, 'updatedOn' => $this->updatedOn, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'IP', $this->IP]);
     return $dataProvider;
 }
示例#2
0
文件: Music.php 项目: IVsevolod/zouk
 public static function getMusic($data)
 {
     $query = Music::find()->andWhere('deleted = 0')->limit(!empty($data['limit']) ? $data['limit'] : 20)->orderBy('id DESC');
     if (!empty($data['userId'])) {
         $query->andWhere('user_id = :user_id', [':user_id' => $data['userId']]);
     }
     if (!empty($data['artistOrTitle'])) {
         $artistOrTitle = '%' . $data['artistOrTitle'] . '%';
         $query->andWhere('artist LIKE :value OR title LIKE :value', [':value' => $artistOrTitle]);
     }
     return $query->all();
 }
 public function search($params)
 {
     $query = Music::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['defaultOrder' => ['Id' => SORT_ASC, 'name' => SORT_ASC]]);
     $query->andFilterWhere([music::tableName() . '.status' => '0']);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['Id' => $this->Id, 'createdOn' => $this->createdOn, 'status' => $this->status, 'updatedOn' => $this->updatedOn, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'IP', $this->IP])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'searchAlias', $this->searchAlias]);
     return $dataProvider;
 }