public function actionZan() { $data = Yii::$app->request->post(); $user = new User(); $phone = $user->find()->select('id')->where(['phone' => $data['phone']])->one(); $info = User::findOne(['phone' => $data['phone']]); if ($info) { $info->favour += 1; $info->save(); echo json_encode(array('flag' => 1, 'msg' => 'favour success.')); } else { echo json_encode(array('flag' => 0, 'msg' => 'favour fail.')); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Zan::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); //$value = 0; if ($params != false && !empty($params['ZanSearch'])) { //$b=$a; //=app::find()->where("name= :name",[':name'=>'QQ'])->one(); //if() foreach ($params['ZanSearch'] as $name => $value1) { if ($name === 'myid' && $value1 != null) { $appinfo = User::findOne(['phone' => $params['ZanSearch']['myid']]); $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(['myid' => $this->value, 'msgid' => $this->msgid]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Judge::find()->join('INNER JOIN', 'user', 'judge.userid=user.id'); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if ($params != false && !empty($params['JudgeSearch'])) { //$b=$a; //=app::find()->where("name= :name",[':name'=>'QQ'])->one(); //if() foreach ($params['JudgeSearch'] as $name => $value1) { if ($name === 'userid' && $value1 != null) { $appinfo = User::findOne(['phone' => $params['JudgeSearch']['userid']]); $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, 'userid' => $this->value, 'created_at' => $this->created_at]); $query->andFilterWhere(['like', 'message', $this->message]); if (isset($params['JudgeSearch']) && isset($params['JudgeSearch']['usernickname'])) { $query->andFilterWhere(['like', 'user.nickname', $params['JudgeSearch']['usernickname']]); } return $dataProvider; }
public function getUser() { if ($this->_user === false) { $this->_user = User::find()->where(['phone' => $this->phone, 'pwd' => md5($this->pwd)])->one(); } return $this->_user; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Message::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if ($params != false && !empty($params['MessageSearch'])) { //$b=$a; //=app::find()->where("name= :name",[':name'=>'QQ'])->one(); //if() foreach ($params['MessageSearch'] as $name => $value1) { if ($name === 'userid' && $value1 != null) { $appinfo = User::findOne(['phone' => $params['MessageSearch']['userid']]); $this->value = $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(['id' => $this->id, 'userid' => $this->value, 'created_at' => $this->created_at]); $query->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'kind', $this->kind])->andFilterWhere(['like', 'area', $this->area]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = User::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); $query->andFilterWhere(['famous' => 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, 'famous' => $this->famous, 'shared' => $this->shared, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'pwd', $this->pwd])->andFilterWhere(['like', 'authKey', $this->authKey])->andFilterWhere(['like', 'nickname', $this->nickname])->andFilterWhere(['like', 'thumb', $this->thumb])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'area', $this->area])->andFilterWhere(['like', 'job', $this->job])->andFilterWhere(['like', 'hobby', $this->hobby])->andFilterWhere(['like', 'signature', $this->signature]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { //$query = Friend::find()->join('INNER JOIN','user','friends.friendid=user.id'); $this->load($params); if (isset($params['FollowSearch']['mynickname']) && !empty($params['FollowSearch']['mynickname'])) { $query = Friend::find()->join('INNER JOIN', 'user', 'friends.myid=user.id'); $query->andFilterWhere(['like', 'user.nickname', $params['FollowSearch']['mynickname']]); } else { $query = Friend::find()->join('INNER JOIN', 'user', 'friends.friendid=user.id'); } $dataProvider = new ActiveDataProvider(['query' => $query]); $query->andFilterWhere(['friends.isfriend' => 0]); if ($params != false && !empty($params['FollowSearch'])) { //$b=$a; //=app::find()->where("name= :name",[':name'=>'QQ'])->one(); //if() foreach ($params['FollowSearch'] as $name => $value1) { if ($name === 'myid' && $value1 != null) { $appinfo = User::findOne(['phone' => $params['FollowSearch']['myid']]); $this->value = $appinfo['id']; if ($appinfo == null) { $this->value = 0; } } if ($name === 'friendid' && $value1 != null) { $appinfo = User::findOne(['phone' => $params['FollowSearch']['friendid']]); $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(['myid' => $this->value, 'friendid' => $this->userinc]); if (isset($params['FollowSearch']) && isset($params['FollowSearch']['friendnickname'])) { $query->andFilterWhere(['like', 'user.nickname', $params['FollowSearch']['friendnickname']]); } return $dataProvider; }
/** * 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; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Reply::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if ($params != false && !empty($params['ReplySearch'])) { foreach ($params['ReplySearch'] as $name => $value1) { if ($name === 'fromid' && $value1 != null) { $appinfo = User::findOne(['fromid' => $params['ReplySearch']['fromid']]); $this->value = $appinfo['id']; if ($appinfo == null) { $this->value = 0; } } if ($name === 'toid' && $value1 != null) { if ($params['ReplySearch']['toid'] == '直接回复消息') { $this->userinc = 0; } else { $appinfo = User::findOne(['phone' => $params['ReplySearch']['toid']]); $this->userinc = $appinfo['id']; if ($appinfo == null) { $this->userinc = 10000000001.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, 'msgid' => $this->msgid, 'fromid' => $this->value, 'toid' => $this->userinc, 'isread' => $this->isread, 'created_at' => $this->created_at]); $query->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getUser() { return $this->hasOne(User::className(), ['id' => 'userid']); }
/** * 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 actionDeleteall($id) { $model = $this->findModel($id); $model->delete(); $user = User::findOne(['id' => $model->myid]); return $this->redirect(['indexofall']); }
public function actionGetMsg() { $dat = Yii::$app->request->post(); $phone = User::findOne(['phone' => $dat['phone']]); $data = (new \yii\db\Query())->select('u.phone,u.thumb,u.nickname,content,kind,m.area,c.created_at,msg')->from('msg m')->join('LEFT JOIN', 'collect_interact c', 'm.id=c.msg')->join('LEFT JOIN', 'user u', 'u.id=m.userid')->where(['c.userid' => $phone['id']]); //return $data; //$data = Message::find ()->select ( 'msg.id' )->join ( 'INNER JOIN', 'collect_interact', ' msg.id =collect_interact.msg and collect_interact.userid = :id ', [':id' => $phone['id'] ]); $pages = new \yii\data\Pagination(['totalCount' => $data->count(), 'pageSize' => '10']); $models = $data->orderBy("created_at desc")->offset($pages->offset)->limit($pages->limit)->all(); $result = array(); $result['item'] = array(); foreach ($models as $model) { // $msg = (new \yii\db\Query())->select(['msg.*','user.nickname','user.thumb'])->from ('msg') // ->join('INNER JOIN', 'user','msg.userid = user.id and msg.id = :id',[':id'=>$model['id']]) // ->one (); //$info=$msg; $info = $model; $info['apps'] = (new \yii\db\Query())->select(['app.*'])->from('msgtoapp')->join('INNER JOIN', 'app', 'app.version>\'\' and msgtoapp.appid = app.id and msgtoapp.msgid = :id', [':id' => $model['msg']])->all(); $info['replys'] = (new \yii\db\Query())->select(['reply.*', 'user1.nickname as fromnickname', 'user1.phone as fromphone', 'user2.nickname as tonickname', 'user2.phone as tophone'])->from('reply')->join('INNER JOIN', 'user user1', 'user1.id = reply.fromid and reply.msgid= :id', [':id' => $model['msg']])->join('Left JOIN', 'user user2', 'user2.id = reply.toid')->orderBy("reply.created_at")->all(); $info['zan'] = (new \yii\db\Query())->select('u.phone,u.nickname')->from('zan z')->join('INNER JOIN', 'user u', 'u.id=z.myid and z.msgid=:id', [':id' => $model['msg']])->all(); $result['item'][] = $info; } $result['_meta'] = array('pageCount' => $pages->pageCount, 'currentPage' => $pages->page + 1); return $result; }
/** * Updates an existing Zan 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['myid']]); $model['myid'] = $userinfo['phone']; $data = Yii::$app->request->post(); if ($data != false) { $userinfo = User::findOne(['phone' => $data['Zan']['myid']]); $model->myid = (string) $userinfo['id']; $model->msgid = $data['Zan']['msgid']; if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model]); } } else { return $this->render('update', ['model' => $model]); } }
/** * Updates an existing Reply 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['fromid']]); if ($model['toid'] == 0) { $model['fromid'] = $userinfo['phone']; $model['toid'] = '直接回复消息'; } else { $appinfo = User::findOne(['id' => $model['toid']]); $model['fromid'] = $userinfo['phone']; $model['toid'] = $appinfo['phone']; } $data = Yii::$app->request->post(); if ($data != false) { $userinfo = User::findOne(['phone' => $data['Reply']['fromid']]); if ($data['Reply']['toid'] == '直接回复消息') { $model->toid = 0; } else { $appinfo = User::findOne(['name' => $data['Reply']['toid']]); $model->toid = $appinfo['id']; } $model->msgid = $data['Reply']['msgid']; $model->fromid = $userinfo['id']; $model->created_at = (string) time(); $model->isread = $data['Reply']['isread']; $model->content = $data['Reply']['content']; 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 actionReply() { $data = Yii::$app->request->post(); $user = new User(); $fromphone = $user->find()->select('id')->where(['phone' => $data['fphone']])->one(); $model = new Reply(); if ($data['tphone'] == '') { $model->toid = 0; } else { $tophone = $user->find()->select('id')->where(['phone' => $data['tphone']])->one(); $model->toid = $tophone['id']; } $to = Message::findOne(['id' => $data['msgid']]); if ($fromphone['id'] != $to['id']) { $model3 = new Notify(); $model3->from = $fromphone['id']; $model3->to = $to['userid']; $model3->message = '评论'; $model3->created_at = time(); if (!$model3->save()) { echo json_encode(array('flag' => 0, 'msg' => 'Reply failed!')); return; } } $model->fromid = $fromphone['id']; $model->msgid = $data['msgid']; $model->content = $data['content']; $model->isread = 0; $model->created_at = time(); if ($model->save()) { echo json_encode(array('flag' => 1, 'msg' => 'Reply success!')); } else { echo json_encode(array('flag' => 0, 'msg' => 'Reply failed!')); } }
public function actionSearchStar() { $data = Yii::$app->request->post(); Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $model = new User(); $ans = $model->find()->select('*')->from('user')->where('famous=1')->andWhere(['like', 'nickname', $data['name']])->all(); return $ans; }
/** * @return \yii\db\ActiveQuery */ public function getTo0() { return $this->hasOne(User::className(), ['id' => 'to']); }
public function actionUpload() { $data = Yii::$app->request->post(); $phone = User::findOne(['phone' => $data['phone']]); foreach ($data['apps'] as $app) { $a = Appl::findOne(['package' => $app[1]]); if ($a) { $model = new Usertoapp(); $model->userid = $phone->id; $model->appid = $a->id; $model->created_at = time(); if (!$model->save()) { echo json_encode(array('flag' => 0, 'msg' => 'Upload your app failed!')); return; } } else { $model1 = new Appl(); $model1->name = $app[0]; $model1->package = $app[1]; $model1->updated_at = time(); if (!$model1->save()) { echo json_encode(array('flag' => 0, 'msg' => 'Upload your app failed!')); return; } $a1 = Appl::findOne(['package' => $app[1]]); $model2 = new Usertoapp(); $model2->userid = $phone->id; $model2->appid = $a1->id; $model2->created_at = time(); if (!$model2->save()) { echo json_encode(array('flag' => 0, 'msg' => 'Upload your app failed!')); return; } } } echo json_encode(array('flag' => 1, 'msg' => 'Upload your app success!')); }
/** * @return \yii\db\ActiveQuery */ public function getMy() { return $this->hasOne(User::className(), ['id' => 'myid']); }
public function actionLike() { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $data = Yii::$app->request->post(); $model = new User(); $myid = $model->find()->select('id')->where(['phone' => $data['phone']])->one(); $aa = (new \yii\db\Query())->select('a.*')->from('friends f')->join('INNER JOIN', 'usertoapp ua', 'f.friendid=ua.userid and f.friendid <> f.myid and f.myid=:id', ['id' => $myid['id']])->join('INNER JOIN', 'app a', 'ua.appid=a.id')->all(); return $aa; }
public function actionGuess() { $data = Yii::$app->request->post(); $userinfo = User::findOne(['phone' => $data['phone']]); $arrs = explode(' ', $userinfo['hobby']); $ans = array(); $num = 0; for ($i = 0; $i < count($arrs); $i++, $num++) { $aa = (new \yii\db\Query())->select('a.*')->from('app a')->join('INNER JOIN', 'appofkind ak', 'a.id=ak.appid')->where(['ak.kind' => $arrs[$i]])->all(); if ($aa) { foreach ($aa as $a) { $point = 0; for ($j = 0; $j < count($ans); $j++) { if ($a['id'] == $ans[$j]['id']) { $point = 1; break; } } if ($point == 0) { $ans[] = $a; } } } } //$ans=array_unique($ans); return $ans; }
/** * Finds the User model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return User the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = User::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }