Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Appcomments::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     //$value = 0;
     if ($params != false && !empty($params['AppcommentsSearch'])) {
         //$b=$a;
         //=app::find()->where("name= :name",[':name'=>'QQ'])->one();
         //if()
         foreach ($params['AppcommentsSearch'] as $name => $value1) {
             if ($name === 'appid' && $value1 != null) {
                 $appinfo = app::findOne(['name' => $params['AppcommentsSearch']['appid']]);
                 $this->value = $appinfo['id'];
                 if ($appinfo == null) {
                     $this->value = 0;
                 }
             }
             if ($name === 'userid' && $value1 != null) {
                 $appinfo = User::findOne(['phone' => $params['AppcommentsSearch']['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(['appid' => $this->value, 'userid' => $this->userinc, 'commentstars' => $this->commentstars, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'userthumb', $this->userthumb])->andFilterWhere(['like', 'usernickname', $this->usernickname])->andFilterWhere(['like', 'comments', $this->comments])->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 public function actionTestl()
 {
     echo "sss";
     $dataProvider = new ActiveDataProvider(['query' => Appcomments::find()]);
     //$dataProvider->keys;
     //$dataProvider->models;
     /*$dataProvider->setPagination(false);
     		$mymodel=$dataProvider->models;
     		foreach ($mymodel as $model){
     			echo $model['appid'];
     			
     		}*/
     $pagination = $dataProvider->getPagination();
     var_dump($pagination->page);
     $count = 0;
     while ($categories = $dataProvider->models) {
         /*foreach ($categories as $model) {
         			$model['appid']=0;
         		}*/
         //echo $pagination->page=1+$count;
         $count++;
         $dataProvider->setPagination($count);
     }
     //$mymodel[4]['kind']="bbbbbb";
     //$dataProvider->setModels($mymodel);
     //var_dump($dataProvider->models[4]['kind']);
     //echo $dataProvider->models;
 }