/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Usertoapp::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if ($params != false && !empty($params['UsertoappSearch'])) {
         //$b=$a;
         //=app::find()->where("name= :name",[':name'=>'QQ'])->one();
         //if()
         foreach ($params['UsertoappSearch'] as $name => $value1) {
             if ($name === 'appid' && $value1 != null) {
                 $appinfo = app::findOne(['name' => $params['UsertoappSearch']['appid']]);
                 $this->value = $appinfo['id'];
                 if ($appinfo == null) {
                     $this->value = 0;
                 }
             }
             if ($name === 'userid' && $value1 != null) {
                 $appinfo = User::findOne(['phone' => $params['UsertoappSearch']['userid']]);
                 $this->userinc = $appinfo['id'];
                 if ($appinfo == null) {
                     $this->userinc = 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(['userid' => $this->userinc, 'appid' => $this->value, 'created_at' => $this->created_at]);
     return $dataProvider;
 }
 /**
  * Displays a single Apptopicture model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $appinfo = app::findOne(['id' => $model['appid']]);
     $model['appid'] = $appinfo['name'];
     return $this->render('view', ['model' => $model]);
 }
Beispiel #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = app::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     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, 'stars' => $this->stars, 'downloadcount' => $this->downloadcount, 'commentscount' => $this->commentscount, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'version', $this->version])->andFilterWhere(['like', 'profile', $this->profile])->andFilterWhere(['like', 'android_url', $this->android_url])->andFilterWhere(['like', 'ios_url', $this->ios_url])->andFilterWhere(['like', 'introduction', $this->introduction])->andFilterWhere(['like', 'size', $this->size])->andFilterWhere(['like', 'icon', $this->icon])->andFilterWhere(['like', 'updated_log', $this->updated_log])->andFilterWhere(['like', 'kind', $this->kind]);
     return $dataProvider;
 }
 /**
  * Updates an existing Usertoapp model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $userinfo = User::findOne(['id' => $model['userid']]);
     $appinfo = app::findOne(['id' => $model['appid']]);
     $model['userid'] = $userinfo['phone'];
     $model['appid'] = $appinfo['name'];
     $data = Yii::$app->request->post();
     if ($data != false) {
         $userinfo = User::findOne(['phone' => $data['Usertoapp']['userid']]);
         $appinfo = app::findOne(['name' => $data['Usertoapp']['appid']]);
         $model->appid = (string) $appinfo['id'];
         $model->userid = $userinfo['id'];
         $model->created_at = (string) time();
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('update', ['model' => $model]);
         }
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
 public function actionRequestresult()
 {
     $app = new app();
     $data = $app->findBySql("select * from app order by id desc limit 1")->all();
     echo $data[0]['id'];
 }
 public function actionTest()
 {
     echo "test";
     $dataProvider = new ActiveDataProvider(['query' => app::find()]);
     $pagination = $dataProvider->getPagination();
     $count = $pagination->pageCount;
     $count1 = 0;
     while ($categories = $dataProvider->models) {
         foreach ($categories as $category) {
             echo $category['id'];
         }
         $count1++;
         if ($count1 > $count) {
             break;
         }
     }
 }
 /**
  * Finds the app model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param integer $id        	
  * @return app the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = app::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionUpdateofmsg($id)
 {
     $model = $this->findModel($id);
     $appinfo = app::findOne(['id' => $model['appid']]);
     $model['appid'] = $appinfo['name'];
     $data = Yii::$app->request->post();
     if ($data != false) {
         $appinfo = app::findOne(['name' => $data['Msgtoapp']['appid']]);
         $model->appid = (string) $appinfo['id'];
         if ($model->save()) {
             return $this->redirect(['indexofmsg?MsgtoappSearch%5Bmsgid%5D=' . $model->msgid]);
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('update_msg', ['model' => $model]);
         }
     } else {
         return $this->render('update_msg', ['model' => $model]);
     }
 }
 public function actionViewmsg($id)
 {
     $model = $this->findModel($id);
     $dataProvider = new ActiveDataProvider(['query' => app::find()->join('INNER JOIN', 'msgtoapp', 'msgtoapp.appid = app.id && msgtoapp.msgid = :msgid', [':msgid' => $model->id])]);
     $searchModel = new appSearch();
     return $this->render('/admin/app', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
 }