コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * 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]);
 }
コード例 #3
0
 /**
  * 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]);
     }
 }
コード例 #4
0
 /**
  * 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.');
     }
 }
コード例 #5
0
 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]);
     }
 }