/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Apptopicture::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if ($params != false && !empty($params['ApptopictureSearch'])) {
         //$b=$a;
         //=app::find()->where("name= :name",[':name'=>'QQ'])->one();
         //if()
         foreach ($params['ApptopictureSearch'] as $name => $value1) {
             if ($name === 'appid' && $value1 != null) {
                 $appinfo = app::findOne(['name' => $params['ApptopictureSearch']['appid']]);
                 $this->value = $appinfo['id'];
                 if ($appinfo == null) {
                     $this->value = 0;
                 }
             }
         }
     }
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'appid' => $this->value]);
     $query->andFilterWhere(['like', 'picture', $this->picture]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 public function actionGetapp()
 {
     $data = Yii::$app->request->post();
     $appl = new Appl();
     $apptopic = new Apptopicture();
     $appcom = new Appcomments();
     $appinfo = $appl->find()->where(['id' => $data['appid']])->one();
     $result = array();
     $result['basic'] = $appinfo;
     $apppics = $apptopic->find()->where(['appid' => $data['appid']])->all();
     $result['picture_urls'] = array();
     foreach ($apppics as $apptopic) {
         $result['picture_urls'][] = $apptopic;
     }
     $appcoms = $appcom->find()->where(['appid' => $data['appid']])->all();
     $result['comments'] = array();
     foreach ($appcoms as $appcomment) {
         $result['comments'][] = $appcomment;
     }
     return $result;
 }
 /**
  * Finds the Apptopicture model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Apptopicture the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Apptopicture::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getApptopictures()
 {
     return $this->hasMany(Apptopicture::className(), ['appid' => 'id']);
 }